Unsupported engine node / NPM only when building in Docker - node.js

I have a dependency in my package.json which itself has the following dependency:
"node-rdkafka": "^2.5.0",
Using nvm on my local machine and setting my node version to 8.9.1, and my npm version is 5.5.1, I can successfully run
npm install node-rdkafka#2.7.1
But when running the same thing (i.e npm install) from within my docker image:
FROM node:10.13.0-alpine or FROM node:8.9.1-alpine
I get the following error:
npm ERR! notsup Unsupported engine for node-rdkafka#2.7.1: wanted: {"node":">=12.0.0"} (current: {"node":"10.13.0","npm":"6.4.1"})
npm ERR! notsup Not compatible with your version of node/npm: node-rdkafka#2.7.1
npm ERR! notsup Not compatible with your version of node/npm: node-rdkafka#2.7.1
npm ERR! notsup Required: {"node":">=12.0.0"}
npm ERR! notsup Actual: {"npm":"6.4.1","node":"10.13.0"}
Any ideas about this inconsistency?
I clearly dont need a node version this high. But it says I do.

Try to remove package-lock.json before npm install in Docker
rm package-lock.json
npm i

The engines property in the package.json allows us to establish a range of versions.
With >=12 is asking for a node with version 12 or greater.
Therefore, the solution would be to install the requested version:
FROM node:12
Anyway, I recommend reviewing the versions supported by Docker currently here.

Related

npm ERR! notsup Unsupported engine for #nestjsi/class-validator#0.2.1: wanted: {"node":">=16.0.0"} (current: {"node":"14.19.3","npm":"6.14.17"})

When building a Dockerfile I get:
npm ERR! notsup Required: {"node":">=16.0.0"}
npm ERR! notsup Actual: {"npm":"6.14.17","node":"14.19.3"}
Dockerfile:
FROM abc.xyz.com/abc-xyxa/ab/nodejs:14 As Development
USER root
# set the root's npm configuration to our project's configuration
COPY .npmrc /root/.npmrc
# copy project file
COPY package.json .
# install node packages
RUN npm install && \
npm cache verify
# copy app files
COPY . .
# Set EDT Time Zone
RUN echo America/New_York | tee /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata
# application server port
EXPOSE 3000
# default run command
CMD [ "nest", "start" ]
If i use the version 14 then, i have this error:
npm ERR! code ENOTSUP
npm ERR! notsup Unsupported engine for #nestjsi/class-validator#0.2.1: wanted: {"node":">=16.0.0"} (current: {"node":"14.19.3","npm":"6.14.17"})
npm ERR! notsup Not compatible with your version of node/npm: #nestjsi/class-validator#0.2.1
npm ERR! notsup Not compatible with your version of node/npm: #nestjsi/class-validator#0.2.1
npm ERR! notsup Required: {"node":">=16.0.0"}
npm ERR! notsup Actual: {"npm":"6.14.17","node":"14.19.3"}
npm ERR! A complete log of this run can be found in:
npm ERR! /apps/.npm/cache/_logs/2022-07-22T15_16_09_537Z-debug.log
And if i use the version 16 then I have this error:
npm ERR! Found: rxjs#7.5.6
npm ERR! node_modules/rxjs
npm ERR! rxjs#"^7.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer rxjs#"^6.0.0" from #nestjs/common#7.6.18
Things I already tried:
downgrade the npm version
downgrade the node version
Let me know the feasible solution for this problem
I believe you need to update your #nestjs/common version. It should solve the issue.
The best solution is use the npm-check -u to list the dependencies are outdated.
I tried with nvm use 12 and it worked for me.

How to fix this npm error trying to update

leolemus#Leos-MBP-2 ~ % npm install -g npm#latest
npm does not support Node.js v15.11.0
You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.
You can find the latest version at https://nodejs.org/
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: npm#8.3.0
npm ERR! notsup Not compatible with your version of node/npm: npm#8.3.0
npm ERR! notsup Required: {"node":"^12.13.0 || ^14.15.0 || >=16"}
npm ERR! notsup Actual: {"npm":"8.3.0","node":"v15.11.0"}
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/leolemus/.npm/_logs/2021-12-12T02_35_45_442Z-debug-0.log
I use macos 11.2.2 And I have node installed via homebrew. It says it's up to date when I do "brew upgrade node".
You can always check which version you're using with:
node --version
If you're not using the Node you installed you can unlink the version you don't want with
brew unlink node
Install the node version you want:
brew install node#version
Then link to it with:
brew link node#version
Validate you're using it with:
node --version

Node throws unsupported engine error during build, but actual node version is greated than required

I'm encountering an unsupported node version in my CI, which runs from a Docker image
Triggering build execution...
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm
npm ERR! notsup Not compatible with your version of node/npm
npm ERR! notsup Required: {"node":">=16.13.0"}
npm ERR! notsup Actual: {"npm":"7.18.1","node":"v16.4.2"}
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-11-26T20_58_56_716Z-debug.log
Error occured during the build.
Note that the actual version 16.4.2 > 16.13.0, so this error should not be occurring?
I do have this exiting out with a stderr because strict mode is on engine-strict=true, but either way the error occurs.
(No issues locally, where I am also running Node 16)
Looks like you misread the version numbers. 13 > 4.
From https://nodejs.org/en/download/releases/:
Node.js 16.4.2 2021-07-05
Node.js 16.13.0 2021-10-26

npm install lite-server --save-dev error

I'm trying to use node for the first time in a VS project in windows. I installed node.js, below is the info:
node -v
v8.9.3
npm -v
5.5.1
Completed setup in the project using npm init, that seemed to work fine.
npm install lite-server --save-dev produced the following error:
$ npm install lite-server --save-dev
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents#1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS: darwin
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: win32
npm ERR! notsup Actual Arch: x64
I don't understand the errors. Help. Thanks!
The error comes from fsevents#1.1.3, which is a dependency package of lite-server.
fsevents#1.1.3 only works in macOS. See its npm info page.
Native access to OS X FSEvents in Node.js
The FSEvents API in OS X allows applications to register for
notifications of changes to a given directory tree. It is a very fast
and lightweight alternative to kqueue.
Similar issues also apply to other npm packages with such dependency.
I am using npm#5.6.0, the latest stable release, and tried install on my Windows. The error turns out to a warning and let lite-server installed eventually. Anyway, fsevents is just an optional dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.1.3 (node_modules\lite-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ lite-server#2.3.0
added 279 packages in 81.466s
I found the fix for Ubuntu 18.04/20.04 after working for whole day. This should work for other Linux distros
Run following command for globally using lite-server
sudo npm install lite-server -g
Your package.json file should contain
"devDependencies": {
"lite-server": "^2.5.4"
}
and scipt should look like
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server"
},
For development mode run following
sudo npm i lite-server --save-dev
Local server could started using npm command
npm start

how do I install npm packages in linux machine

I've installed nodejs v7.5.0 and npm v4.1.2 in my 32 bit linux mint machine. while I'm typin' npm install into terminal, it gives me these informations instead of being installed npm packages are:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"ia32"})
npm WARN #angular/core#2.4.7 requires a peer of rxjs#^5.0.1 but none was installed.
npm WARN shwokat#1.0.0 No description
npm WARN shwokat#1.0.0 No repository field
Now where's my wrong? how to solve it and install npm packages correctly, please let me know?
Try sudo npm install npm -g
Go through the official guide.

Resources