node-red / node-red-docker

Repository for all things Node-RED and Docker related
Apache License 2.0
481 stars 383 forks source link

Palette editor disabled : npm command not found #326

Closed cbackas closed 2 years ago

cbackas commented 2 years ago

What are the steps to reproduce?

Download and run nodered/node-red:3.0.1 (I found this issue on the 'latest' tag)

What happens?

Error in console: Palette editor disabled : npm command not found and Palette Manager not accessible. Also can't do 'npm install x' commands via docker exec.

What do you expect to happen?

Palette Manager to load normally with access to npm. Version 3.0.0 does load the Palette Manager correctly, but I still can't do npm commands via docker exec. Using 3.0.0-14 makes npm usable via the CLI.

Please tell us about your environment:

Linux 5.15.46-Unraid x64 LE, node-red in docker

I do provide the extra docker args --user 99:100 to my container

Logs:

22 Jul 21:01:32 - [info] 

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

22 Jul 21:01:32 - [info] Node-RED version: v3.0.1
22 Jul 21:01:32 - [info] Node.js  version: v16.16.0
22 Jul 21:01:32 - [info] Linux 5.15.46-Unraid x64 LE
22 Jul 21:01:33 - [info] Palette editor disabled : npm command not found
22 Jul 21:01:33 - [info] Loading palette nodes
22 Jul 21:01:33 - [info] Settings file  : /data/settings.js
22 Jul 21:01:33 - [info] Context store  : 'default' [module=memory]
22 Jul 21:01:33 - [info] User directory : /data
22 Jul 21:01:33 - [warn] Projects disabled : editorTheme.projects.enabled=false
22 Jul 21:01:33 - [info] Flows file     : /data/flows.json
22 Jul 21:01:33 - [info] Creating new flow file
22 Jul 21:01:33 - [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.
---------------------------------------------------------------------

22 Jul 21:01:33 - [warn] Encrypted credentials not found
22 Jul 21:01:33 - [info] Server now running at http://127.0.0.1:1880/
22 Jul 21:01:33 - [info] Starting flows
22 Jul 21:01:33 - [info] Started flows

don't want to point any fingers but https://github.com/node-red/node-red-docker/pull/324 :P

Dennis14e commented 2 years ago

Got the same issue. Container runs with user 65534:65534

Run via docker exec -it node-red-container /bin/sh:

/usr/src/node-red $ id -u
65534
/usr/src/node-red $ id -g
65534
/usr/src/node-red $ npm

/usr/src/node-red $ echo $?
243
hardillb commented 2 years ago

What version of docker? The node-red user should be 1000 unless alpine have changed something else

hardillb commented 2 years ago

Please supply the full command line of how you are starting Node-RED, including any volumes.

The changes in #324 have not changed the path at all.

Dennis14e commented 2 years ago

Docker version 20.10.17 uid and gid were set by me, I only specified them now because error 243 seems to have something to do with permissions. With version 3.0.0 everything worked without problems.

My docker-compose.yml:

version: "3.7"

services:
  node-red:
    image: nodered/node-red:latest-16
    restart: unless-stopped
    user: "65534:65534"
    environment:
      - TZ=Europe/Berlin
    volumes:
      - ./data:/data
cbackas commented 2 years ago

Docker version 20.10.14, build a224086

I run unraid so I've just got this container configured via the UI with the basic template, but here's the command that's run after it collects that data: docker run -d --name='NodeRed-OfficialDocker' --net='bridge' -e TZ="America/Chicago" -e HOST_OS="Unraid" -e HOST_HOSTNAME="Purple" -e HOST_CONTAINERNAME="NodeRed-OfficialDocker" -e 'NODE_RED_ENABLE_SAFE_MODE'='false' -e 'TZ'='America/Chicago' -p '1880:1880/tcp' -v '/mnt/user/appdata/nodered3/':'/data':'rw' --user 99:100 'nodered/node-red:3.0.1'

@hardillb My thinking regarding #324 was at first that it just stopped working after that PR... but so digging in to why that could possibly be, it seems the --cache flag isn't set explicitly like it was in the old docker entrypoint, but the --userDir flag is. Do you think this could possibly be related?

hardillb commented 2 years ago

nope, it shouldn't be anything to do with the cache as that is only used when installing nodes (not when calling the package.json scripts) it was meaningless in the earlier releases.

I have reproduced this, but it's going to take some playing with.

hardillb commented 2 years ago

Also I'm seeing it fail with both 3.0.1 and 3.0.0

hardillb commented 2 years ago

OK, I know what the problem is, it is the cache and a lack of home directory.

cbackas commented 2 years ago

nope, it shouldn't be anything to do with the cache as that is only used when installing nodes (not when calling the package.json scripts) it was meaningless in the earlier releases.

I have reproduced this, but it's going to take some playing with.

OK, I know what the problem is, it is the cache and a lack of home directory.

I was playing with it the other day and ended up having to add the cache and home dir flags to npm install commands and then it would work. So just need to add a thingy to the dockerfile or the entrypoint to set the flags?

hardillb commented 2 years ago

About to board a plane with no space to keep working on this. Will look when I get home.

cbackas commented 2 years ago

About to board a plane with no space to keep working on this. Will look when I get home.

Cool beans!

hardillb commented 2 years ago

If you can build from source (docker-custom will do) please test this branch

https://github.com/hardillb/node-red-docker/tree/npm-cache-fix

Dennis14e commented 2 years ago

I build from source (using docker-alpine.sh) and it seems like it works now. I updated a module as a test and that worked.

hardillb commented 2 years ago

fixed by #327

Docker containers respun and on Docker hub