简体   繁体   English

仅在 Docker 中构建时不支持的引擎节点/NPM

[英]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-alpineFROM 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.

相关问题 NPM 警告:“不支持的引擎” - NPM warning: 'unsupported engine' npm WARN EBADENGINE npm 安装上不支持的引擎 - npm WARN EBADENGINE Unsupported engine on npm install npm 错误。 notsup @nestjsi/class-validator@0.2:1 不支持的引擎:想要:{"node".">=16.0:0"}(当前:{"node"."14.19,3":"npm"."6.14 .17"}) - 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 WARN notsup sequelize@6.1.0 不支持的引擎:想要:{“node”:“>=10.0.0”} - npm WARN notsup Unsupported engine for sequelize@6.1.0: wanted: {“node”:“>=10.0.0”} 在Docker中构建时出现node-sass错误 - node-sass error when building in Docker Angular “npm i”不支持的引擎错误消息 - Angular “npm i” Unsupported engine error message 构建 docker 图像会引发 gyp ERR! 安装npm时不行 - building docker image throws gyp ERR! not ok when installing npm 运行brew install节点时,npm没有建立 - npm isn't building when I run brew install node 使用多阶段 docker 从源构建节点导致 cli.js 上的 NPM 模块错误 - Building Node from source with multi-stage docker leads to NPM module errors on cli.js 从节点映像运行 docker 容器时找不到 Npm - Npm not found when running docker container from node image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM