Adding dependency in container package.json

{
"name": "node-red-project",
"description": "A Node-RED Project",
"version": "2.6.0",
"private": true,
"dependencies": {}
}

I am copying this package.json in the /data folder and installing using npm install in docker file like below. In my image i am also installing nr-launcher package. What i know is the nr-launcher override the package.json in the /data/package.json . then if i add dependency in this file it will get override. I am looking for a solution to add dependency package in my image and that will not be override by the nr-launcher,

COPY package.json /data

WORKDIR /data

RUN npm install

USER root

RUN mkdir -p /usr/local/ssl-certs

WORKDIR /usr/src/flowforge-nr-launcher

RUN chown -R node-red:node-red /data /usr/src/flowforge-nr-launcher

USER node-red

RUN npm install @flowfuse/nr-launcher@${BUILD_TAG}

Since you mention FlowFuse, packages are added to package.json when you either add them in the Node-RED palette manager or you add them in FlowFuse Hosted Instance settings.

{
"name": "node-red-project",
"description": "A Node-RED Project",
"version": "2.6.0",
"private": true,
"dependencies": {
"@test/custom-node": "*"
}
}

Can i add like this because i want something like this when the instance start it will install my custom-node automatically. When any instance will be created it will install this custom-node in the background and will be available in ./data/package.json.

Is your custom node published on npm? Or do you use a private registry with your FlowFuse installation?

I am using github private registry

Create a project template in flowfuse with your default packages

You need to make your node available either via npm or via a private (npm type) registry.

See: How to Use Private Custom Nodes in FlowFuse? • FlowFuse

Yes i can create application template and put that in pallet dependency. But then every time i create new application template then i need to put the dependency in the application pallet dependency.

what i want in the docker image i will put my custom node in the package.json or i will install it in the ./data/package.json from the docker file. But the problem is nr-launcher overrides the package.json file and takes the package.json from application template pallet dependency.

Add your packages where core packages are located in node-red. Then build the image with your "custom node-red core packages"

I can install the private nodes from the docker file but the problem is nr-launcher override the package.json that is in ./data/package.json. And when i inspect node_modules in ./data/node_modules i found my nodes is not there ony the nodes that is defined in application level template is there.

Once you upload your node to npm or a private registry, you use the node-red palette manager or the instance settings -> modules list. Then it will be added to the package file.

Can you give me an example docker file?

Find where node-red is installed in your image. Locate its node_modules folder. Locate @node-red/nodes/core folder. Put your nodes there. You can use a copy command in your docker image spec