加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – 构建docker镜像时无法npm安装依赖项

发布时间:2020-12-14 01:57:21 所属栏目:Windows 来源:网络整理
导读:我正在构建一个Dockerfile中的图像,并且我构建映像时我的npm安装依赖项的部分是错误的,但我可以在它之外运行命令.我不确切地知道这个错误的来源. 我在Windows上使用boot2docker,我的Dockerfile是: FROM ubuntu:15.04RUN apt-get -y update RUN apt-get -y i
我正在构建一个Dockerfile中的图像,并且我构建映像时我的npm安装依赖项的部分是错误的,但我可以在它之外运行命令.我不确切地知道这个错误的来源.

我在Windows上使用boot2docker,我的Dockerfile是:

FROM ubuntu:15.04

RUN apt-get -y update 
RUN apt-get -y install nodejs 
RUN apt-get -y install npm 

COPY /server /src
COPY /server/package.json /tmp/package.json

RUN cd /tmp && npm install

(etc)

错误消息是:

sh:1 node: not found
npm WARN: This failure might be due to the use of legacy binary "node"
npm WARN: For further explanations,please read
/usr/share/doc/nodejs/README.Debian

npm ERR! sails@0.11.0 preinstall: 'node ./lib/preinstall_npmcheck.js'
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the sails@0.11.0 preinstall script.
npm ERR! This is most likely a problem iwth the sails package,npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!      node ./lib/preinstall_npmcheck.js
npm ERR! You can get their info via:
npm ERR!      npm owner ls sails
npm ERR! There is additional logging output above.

npm ERR! System Linux 4.0.3-boot2docker
npm ERR! command "usr/bin/nodejs" "/usr/bin/npm" "install"

npm ERR! node -v v0.10.25
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!      /tmp/npm-debug.log
npm ERR! not ok code 0
INFO[0633] THe command [/bin/sh -c cd /tmp && install] returned a non-zero code: 1

虽然它说它可能是Sails的问题,但我在我的机器上安装它没有问题.当我运行图像时(显然)我无法安装它,当我尝试运行ubuntu:15.04图像并在那里安装npm和Sails时,它告诉我npm是一个未找到的命令.

我还是Docker的新手(对Windows–我甚至找不到npm-debug.log)所以任何类型的建议都有很大帮助.

谢谢!

解决方法

这是nodejs安装的问题,这里有一个问题: what are the differences between node.js and node?

很明显,有三种方法可以解决这个问题:自己创建符号链接,使用nvm,或者安装nodejs-legacy而不是nodejs:

运行apt-get -y安装nodejs-legacy

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读