Cannot to start Node-RED Docker custom container with npm

Hi, everyone. I have some problems with my container.
I have followed the step with Cannot seem to start Node-RED Docker custom container . But in the last step, which he says "The package.json file didn't have "node-red" as a dependency and therefore npm wasn't installing the package.". I didn't know how to add "node-red" into the package.json. Actually, I have add once but it doesn't work. The package.json is below.

package.json

{
    "name": "node-red-project",
    "description": "A Node-RED Project",
    "version": "0.0.1",
    "private": true,
    "dependencies": {
        "node-red": "1.2.6",
        "node-red-contrib-buffer-array": "~1.1.0",
        "node-red-contrib-counter": "~0.1.6",
        "node-red-contrib-modbus": "~5.13.3",
        "node-red-contrib-opc-da": "~1.0.3",
        "node-red-contrib-opcda-client": "0.0.5",
        "node-red-contrib-opcua": "~0.2.89",
        "node-red-contrib-re-postgres": "~0.2.2",
        "node-red-contrib-redis": "~1.3.7",
        "node-red-dashboard": "~2.25.0",
        "node-red-node-mysql": "~0.1.1",
        "node-red-node-random": "~0.2.0",
        "node-red-node-serialport": "~0.11.1"
    }
}

Dockerfile

FROM nodered/node-red:latest

# Copy package.json to the WORKDIR so npm builds all
# of your added nodes modules for Node-RED
COPY package.json /data/
RUN npm install --only=production

# Copy _your_ Node-RED project files into place
# NOTE: This will only work if you DO NOT later mount /data as an external volume.
#       If you need to use an external volume for persistence then
#       copy your settings and flows files to that volume instead.
COPY settings.js /data/settings.js
COPY flows_nodered.json /data/flows.json

# User configuration directory volume
VOLUME ["/data"]
EXPOSE 1880

CMD ["npm", "start"]

After I build the image and run the image. The response is the nodes are missing. That's means the node_module doesn't work with npm install .

Response

> node-red-docker@1.2.6 start /usr/src/node-red
> node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data" "npm" "start"

18 Jan 07:55:31 - [info]

Welcome to Node-RED
===================

18 Jan 07:55:32 - [info] Node-RED version: v1.2.6
18 Jan 07:55:32 - [info] Node.js  version: v10.23.0
18 Jan 07:55:32 - [info] Linux 4.15.0-76-generic x64 LE
18 Jan 07:55:32 - [info] Loading palette nodes
18 Jan 07:55:34 - [info] Settings file  : /data/settings.js
18 Jan 07:55:34 - [info] Context store  : 'default' [module=memory]
18 Jan 07:55:34 - [info] User directory : /data
18 Jan 07:55:34 - [warn] Projects disabled : editorTheme.projects.enabled=false
18 Jan 07:55:34 - [info] Flows file     : /data/flows.json
18 Jan 07:55:34 - [info] Server now running at http://127.0.0.1:1880/
18 Jan 07:55:34 - [warn]

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

18 Jan 07:55:34 - [info] Waiting for missing types to be registered:
18 Jan 07:55:34 - [info]  - modbus-client
18 Jan 07:55:34 - [info]  - OpcUa-Endpoint
18 Jan 07:55:34 - [info]  - redis-config
18 Jan 07:55:34 - [info]  - ui_tab
18 Jan 07:55:34 - [info]  - ui_base
18 Jan 07:55:34 - [info]  - ui_group
18 Jan 07:55:34 - [info]  - MySQLdatabase
18 Jan 07:55:34 - [info]  - postgresdb
18 Jan 07:55:34 - [info]  - modbus-read
18 Jan 07:55:34 - [info]  - modbus-flex-write
18 Jan 07:55:34 - [info]  - random
18 Jan 07:55:34 - [info]  - OpcUa-Item
18 Jan 07:55:34 - [info]  - OpcUa-Client
18 Jan 07:55:34 - [info]  - redis-in
18 Jan 07:55:34 - [info]  - redis-out
18 Jan 07:55:34 - [info]  - ui_switch
18 Jan 07:55:34 - [info]  - ui_text_input
18 Jan 07:55:34 - [info]  - ui_gauge
18 Jan 07:55:34 - [info]  - modbus-flex-getter
18 Jan 07:55:34 - [info]  - OpcUa-Browser
18 Jan 07:55:34 - [info]  - OpcUa-Server
18 Jan 07:55:34 - [info]  - ui_template
18 Jan 07:55:34 - [info]  - modbus-response
18 Jan 07:55:34 - [info]  - modbus-server
18 Jan 07:55:34 - [info]  - mysql
18 Jan 07:55:34 - [info]  - postgres
18 Jan 07:55:34 - [info]  - redis-command
18 Jan 07:55:34 - [info]  - redis-lua-script
18 Jan 07:55:34 - [info]  - ui_chart
18 Jan 07:55:34 - [info]  - ui_audio
18 Jan 07:55:34 - [info]  - ui_toast
18 Jan 07:55:34 - [info]  - ui_text
18 Jan 07:55:34 - [info]  - ui_colour_picker
18 Jan 07:55:34 - [info]  - ui_date_picker
18 Jan 07:55:34 - [info]  - ui_numeric
18 Jan 07:55:34 - [info]  - ui_slider
18 Jan 07:55:34 - [info]  - ui_button

So, how can I add the "node-red" into package.json or how to fix the package.json. Hoping guys can help me to build it successfully. Thanks a lot.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.