node-red-docker icon indicating copy to clipboard operation
node-red-docker copied to clipboard

node-red container trying to invoke `npm update`?

Open marcinjahn opened this issue 5 years ago • 5 comments

#170

What are the steps to reproduce?

Run node-red dockerized without permissions to use npm update

What happens?

This error:

> [email protected] start /usr/src/node-red
> node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/files"
27 Oct 15:55:46 - [info]
Welcome to Node-RED
===================
27 Oct 15:55:46 - [info] Node-RED version: v1.2.2
27 Oct 15:55:46 - [info] Node.js  version: v10.22.1
27 Oct 15:55:46 - [info] Linux 4.15.0-20-generic x64 LE
27 Oct 15:55:46 - [info] Loading palette nodes
27 Oct 15:55:46 - [info] Settings file  : /files/settings.js
27 Oct 15:55:46 - [info] Context store  : 'default' [module=memory]
27 Oct 15:55:46 - [info] User directory : /files
27 Oct 15:55:46 - [warn] Projects disabled : editorTheme.projects.enabled=false
27 Oct 15:55:46 - [info] Flows file     : /files/flows.json
27 Oct 15:55:46 - [info] Creating new flow file
27 Oct 15:55:46 - [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.
---------------------------------------------------------------------
27 Oct 15:55:46 - [info] Starting flows
27 Oct 15:55:46 - [info] Started flows
27 Oct 15:55:46 - [info] Server now running at http://127.0.0.1:1880/
27 Oct 15:57:18 - [info] Stopping flows
27 Oct 15:57:18 - [info] Stopped flows
┌──────────────────────────────────────────────┐
│           npm update check failed            │
│     Try running with sudo or get access      │
│     to the local update config store via     │
│ sudo chown -R $USER:$(id -gn $USER) /.config │
└──────────────────────────────────────────────┘

What do you expect to happen?

No npm update check. I don't understand why npm update even happens in the container? Shouldn't the app just npm start with the dependencies being "frozen" at the versions that were available during image build?

Please tell us about your environment:

[ ] Platform/OS: Ubuntu 18.04

[ ] Browser:

  • If you are a Portainer user, please attach a screenshot of your container details.

    Containers -> Click on the node-red container -> Scroll to Container Details and take a screenshot
    
  • If you are a command line user please execute the following command and attach the log file.

    docker inspect <container_id> > container.log
    

marcinjahn avatar Oct 28 '20 10:10 marcinjahn

When we start we do a check to see if npm is installed (so you can add extra nodes). Currently we do this just as a call to npm -v - and that indeed should fail if not executable - but seems to be passing or you would get another error earlier in the log saying npm not available. However I do not recognise that error message you are getting - do you have any extra non-core nodes installed ?

dceejay avatar Oct 28 '20 10:10 dceejay

Whenever npm is run (regardless of what command its running) it checks to see if there's an update available. It then prints out the resulting message (if there is an update or error) as part of the process exit so it doesn't get lost the output of the actual npm command.

The docker container starts node-red with npm start... - so when that exists it will print the message you are seeing.

The fix is to update the Dockerfile to include the --no-update-notifier to the npm start command being used.

knolleary avatar Oct 28 '20 11:10 knolleary

do we need to do that for the registry/lib/installer.js npm -v check also ?

dceejay avatar Oct 28 '20 12:10 dceejay

With --no-update-notifier the error no longer appears. However, I still noticed that the container fails around every minute. This time, without any error :(

marcinjahn avatar Oct 28 '20 12:10 marcinjahn

I don't think this is related to the issue as framed... so we can update the dockerfile to add that flag. OK to close ?

dceejay avatar Oct 28 '20 16:10 dceejay