Unsupported engine node / NPM only when building in Docker
Solution 1
Try to remove package-lock.json before npm install in Docker
rm package-lock.json
npm i
Solution 2
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.
Greg Peckory
Updated on July 29, 2022Comments
-
Greg Peckory 5 monthsI have a dependency in my
package.jsonwhich itself has the following dependency:"node-rdkafka": "^2.5.0",Using
nvmon my local machine and setting my node version to8.9.1, and mynpmversion is5.5.1, I can successfully runnpm install [email protected]But when running the same thing (i.e
npm install) from within my docker image:FROM node:10.13.0-alpineorFROM node:8.9.1-alpineI get the following error:
npm ERR! notsup Unsupported engine for [email protected]: 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: [email protected] npm ERR! notsup Not compatible with your version of node/npm: [email protected] 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.
-
Linas almost 2 yearsThat doesn't fix it for me.