SeAlGhz
SeAlGhz

Reputation: 75

how to run Node-Red in docker using windows

I use this command in windows I actually don't know where node_red_data is.

docker run -it -p 1882:1880 -v node_red_data:/data nodered/node-red

and I got following error.

npm ERR! code EJSONPARSE
npm ERR! file /usr/src/node-red/package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected end of JSON input while parsing near ''
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.

npm ERR! A complete log of this run can be found in:
npm ERR!     /data/.npm/_logs/2021-01-26T11_44_30_912Z-debug.log

this is also my log file this file is created automatically inside my node_red_data folder

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   '--no-update-notifier',
1 verbose cli   '--no-fund',
1 verbose cli   'start',
1 verbose cli   '--cache',
1 verbose cli   '/data/.npm',
1 verbose cli   '--',
1 verbose cli   '--userDir',
1 verbose cli   '/data' ]
2 info using [email protected]
3 info using [email protected]
4 verbose config Skipping project config: /usr/src/node-red/.npmrc. (matches userconfig)
5 verbose stack Error: Failed to parse json
5 verbose stack Unexpected end of JSON input while parsing near ''
5 verbose stack     at parseError (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:470:11)
5 verbose stack     at parseJson (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:105:26)
5 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:52:5
5 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:123:16
5 verbose stack     at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
6 verbose cwd /usr/src/node-red
7 verbose Linux 4.19.128-microsoft-standard
8 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "--no-update-notifier" "--no-fund" "start" "--cache" "/data/.npm" "--" "--userDir" "/data"
9 verbose node v10.23.1
10 verbose npm  v6.14.10
11 error code EJSONPARSE
12 error file /usr/src/node-red/package.json
13 error JSON.parse Failed to parse json
13 error JSON.parse Unexpected end of JSON input while parsing near ''
14 error JSON.parse Failed to parse package.json data.
14 error JSON.parse package.json must be actual JSON, not just JavaScript.
15 verbose exit [ 1, true ]

any help?

Upvotes: 0

Views: 2185

Answers (2)

SeAlGhz
SeAlGhz

Reputation: 75

I just made my own node-red instance. I couldn't work with node-red image.

FROM node
WORKDIR /usr/src/node-red
RUN npm install -g --unsafe-perm node-red
CMD node-red

Upvotes: 0

cellularegg
cellularegg

Reputation: 172

Hey the issue you are facing originates in mounting the volume (-v ...) you need to pass a valid Windows Path as an argument. For more information: Official Docker documentation

Command to run Node-RED as a Docker container: docker run -p 1880:1880 -it -v "<Path-on-your-Windows-OS>:/data" nodered/node-red

Where <Path-on-your-Windows-OS> e.g. C:\Users\<username>\Documents\node-red-docker

Upvotes: 1

Related Questions