[英]Unsupported engine node / NPM only when building in Docker
I have a dependency in my package.json
which itself has the following dependency:我的
package.json
有一个依赖项,它本身具有以下依赖项:
"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在我的本地机器上使用
nvm
并将我的节点版本设置为8.9.1
,我的npm
版本是5.5.1
,我可以成功运行
npm install node-rdkafka@2.7.1
But when running the same thing (ie npm install
) from within my docker image:但是当从我的 docker 镜像中运行相同的东西(即
npm install
)时:
FROM node:10.13.0-alpine
or FROM node:8.9.1-alpine
FROM node:10.13.0-alpine
或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.
但它说我愿意。
The engines property in the package.json
allows us to establish a range of versions. package.json
的engines 属性允许我们建立一系列版本。
With >=12
is asking for a node with version 12 or greater. >=12
是要求版本 12 或更高版本的节点。
Therefore, the solution would be to install the requested version:因此,解决方案是安装请求的版本:
FROM node:12
Anyway, I recommend reviewing the versions supported by Docker currently here .无论如何,我建议在此处查看 Docker 当前支持的版本。
Try to remove package-lock.json
before npm install
in Docker 尝试在Docker上
npm install
之前删除package-lock.json
rm package-lock.json
npm i
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.