node-red / node-red-docker

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

NPM fails to install due to running node v14 instead of recommend v16 #375

Closed notexpected closed 1 year ago

notexpected commented 1 year ago

Issue seems to be related to the docker image is not running the recommended Node Version 16 documented here. https://nodered.org/docs/faq/node-versions

What are the steps to reproduce?

Docker File:

FROM nodered/node-red:latest
ENV TZ America/New_York
RUN npm install node-red-contrib-actionflows \
                node-red-contrib-home-assistant-websocket \
                node-red-contrib-stoptimer \
                node-red-contrib-time-range-switch \
                node-red-contrib-timecheck \
                node-red-node-timeswitch \
                node-red-contrib-chronos \
        node-red-contrib-influxdb node-red-contrib-cast node-red-contrib-bigtimer

Attempt to start the above image

What happens?

node-red-contrib-home-assistant-websocket fails to install with:

node-red | 26 May 13:50:37 - [warn] [node-red-contrib-home-assistant-websocket] Node module cannot be loaded on this version. Requires: >=3.0.0

What do you expect to happen?

It installs properally

Please tell us about your environment:

[ ] Platform/OS: Ubuntu Docker version 24.0.1, build 6802122

Logs

node-red  | Welcome to Node-RED
node-red  | ===================
node-red  | 
node-red  | 23 May 00:36:39 - [info] Node-RED version: v2.2.2
node-red  | 23 May 00:36:39 - [info] Node.js  version: v14.18.2
node-red  | 23 May 00:36:39 - [info] Linux 5.19.0-41-generic x64 LE
node-red  | 23 May 00:36:39 - [info] Loading palette nodes
node-red  | 23 May 00:36:40 - [warn] [node-red-contrib-home-assistant-websocket] Node module cannot be loaded on this version. Requires: >=3.0.0*
node-red  | 23 May 00:36:41 - [info] Settings file  : /data/settings.js
node-red  | 23 May 00:36:41 - [info] Context store  : 'default' [module=memory]
node-red  | 23 May 00:36:41 - [info] User directory : /data
node-red  | 23 May 00:36:41 - [warn] Projects disabled : editorTheme.projects.enabled=false
node-red  | 23 May 00:36:41 - [info] Flows file     : /data/flows.json
node-red  | 23 May 00:36:41 - [info] Server now running at https://127.0.0.1:1880/
node-red  | 23 May 00:36:41 - [warn] 
node-red  | 
....
node-red  | 23 May 00:36:41 - [info] Waiting for missing types to be registered:
node-red  | 23 May 00:36:41 - [info]  - server
node-red  | 23 May 00:36:41 - [info]  - server-state-changed
node-red  | 23 May 00:36:41 - [info]  - api-current-state
node-red  | 23 May 00:36:41 - [info]  - api-call-service
node-red  | 23 May 00:36:41 - [info]  - poll-state
node-red  | 26 May 13:50:19 - [info] Installing module: node-red-contrib-home-assistant-websocket, version: 0.49.1
node-red  | 26 May 13:50:37 - [info] Installed module: node-red-contrib-home-assistant-websocket
node-red  | 26 May 13:50:37 - [warn] [node-red-contrib-home-assistant-websocket] Node module cannot be loaded on this version. Requires: >=3.0.0 
node-red  | 26 May 13:50:37 - [warn] Installation of module node-red-contrib-home-assistant-websocket failed:
node-red  | 26 May 13:50:37 - [warn] ------------------------------------------
node-red  | 26 May 13:50:37 - [warn] undefined
node-red  | 26 May 13:50:37 - [warn] ------------------------------------------
node-red  | Error: Install failed
node-red  |     at /usr/src/node-red/node_modules/@node-red/registry/lib/installer.js:285:25
node-red  |     at runMicrotasks (<anonymous>)
node-red  |     at processTicksAndRejections (internal/process/task_queues.js:95:5)
node-red  | 26 May 13:50:37 - [error] Error: Install failed
node-red  | 26 May 13:54:43 - [info] Stopping flows
node-red  | 26 May 13:54:43 - [info] Stopped flows
node-red  | 
node-red  | > node-red-docker@2.2.2 start /usr/src/node-red
node-red  | > node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"
knolleary commented 1 year ago

Hi - can you make sure you've pulled the latest nodered/node-red? The logs show you've ended up with Node-RED 2.2 - but that hasn't been the :latest image for quite some time.

$ docker pull nodered/node-red
...
Digest: sha256:c9ab40bfd7957f17dbd5724e41160068df54530e9d1142d32104d5decb3e4371

$ docker run -it -p 1887 --name mynodered2 nodered/node-red
26 May 14:16:07 - [info]

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

26 May 14:16:07 - [info] Node-RED version: v3.0.2
26 May 14:16:07 - [info] Node.js  version: v16.20.0
notexpected commented 1 year ago

Thanks, this helps me notice what I missed in the docs about the suffix on the latest tag.

When I use nodered/node-red and build the config, I get the latest-18 tag

docker compose build node-red
[+] Building 20.8s (4/5)                                                                                                                  
 => [node-red internal] load build definition from Dockerfile                                                                        0.0s
 => => transferring dockerfile: 441B                                                                                                 0.0s
 => [node-red internal] load .dockerignore                                                                                           0.0s
 => => transferring context: 2B                                                                                                      0.0s
 => [node-red internal] load metadata for docker.io/nodered/node-red:latest-18  

If I change it back to nodered/node-red:latest and re-build the config, it still incorrectly tells me the "latest" tagged version is sha256:33334eab19f40e33dfc8a66bfae485fd8936af73dbe7da04dc21c33264f01f52 (digest 33334eab19f4), which is not the same[1] as the actual latest (sha256:84db99f5c4615f146062003f8d8e1aa308c4337b6df9d5fd4668895650c8c94e) on docker hub...

Seems like an issue in my docker instance as docker compose build did not seem to force it to find the new latest...

[1] I can't even find a corresponding package with that digest...so I am going to clear my caches... sorry for the noise

knolleary commented 1 year ago

No problem - I'll close this issue off

hardillb commented 1 year ago

You need to run docker pull nodered/node-red:latest to ensure that your local build environment has pulled the most up to date version.

If you don't do this then it will use what ever it has locally with the tag. Docker does NOT pull pre-req contianers when you build a Dockerfile

Paraphraser commented 1 year ago

I don't know if this will help but I use these aliases:

alias BUILD='docker-compose -f ~/IOTstack/docker-compose.yml up --build -d'
alias REBUILD='docker-compose -f ~/IOTstack/docker-compose.yml build --no-cache --pull'
alias UP='docker-compose -f ~/IOTstack/docker-compose.yml up -d'

substituting the path to your docker-compose.yml

If I want to rebuild a container (eg nodered) from the ground up and be sure the base image comes from Dockerhub:

$ REBUILD nodered
$ UP nodered

If I only need to rerun the local Dockerfile:

$ BUILD nodered

See also IOTstackAliases.

notexpected commented 1 year ago

Okay, so I figured out why I was really confused... I have been using watchtower for soooo long that I had forgotten the nuances of DockerFile. I had assumed it was updating everything (which it was except for the one thing that was in a Dockerfile)....

I ended up removing the Dockerfiler as it was not adding real value since I moved things into a compose file