簡體   English   中英

在Docker映像中更新npm

[英]Updating npm in Docker image

我正在構建一個Node.js Docker映像: docker build . -t imagename docker build . -t imagename ,但是我不斷收到有關npm版本的警告

npm WARN deprecated This version of npm lacks support for important features,
npm WARN deprecated such as scoped packages, offered by the primary npm
npm WARN deprecated registry. Consider upgrading to at least npm@2, if not the
npm WARN deprecated latest stable version. To upgrade to npm@2, run:
npm WARN deprecated 
npm WARN deprecated   npm -g install npm@latest-2
npm WARN deprecated 
npm WARN deprecated To upgrade to the latest stable version, run:
npm WARN deprecated 
npm WARN deprecated   npm -g install npm@latest
npm WARN deprecated 
npm WARN deprecated (Depending on how Node.js was installed on your system, you
npm WARN deprecated may need to prefix the preceding commands with `sudo`, or if
npm WARN deprecated on Windows, run them from an Administrator prompt.)
npm WARN deprecated 
npm WARN deprecated If you're running the version of npm bundled with
npm WARN deprecated Node.js 0.10 LTS, be aware that the next version of 0.10 LTS
npm WARN deprecated will be bundled with a version of npm@2, which has some small
npm WARN deprecated backwards-incompatible changes made to `npm run-script` and
npm WARN deprecated semver behavior.

但是我已經更新了Node.js版本,它仍然無法正常工作:

node -v
v8.9.3
npm -v
5.6.0

我已經運行了npm -g install npm@latest但是仍然無法正常工作。

Dockerfile

FROM alpine:3.1

# Update
RUN apk add --update nodejs

# Install app dependencies
COPY package.json /src/package.json
RUN cd /src; npm -g install npm@latest

# Bundle app source
COPY . /src

CMD ["node", "--harmony","/src/app.js"]

可能是什么原因? 我可以使用節點運行應用程序。

我正在運行Ubuntu 16.04.3 LTS

在Dockerfile中,我改用了最新的阿爾卑斯版本FROM alpine:3.7 ,它可以工作。

在構建映像之前,必須運行docker image pull node以本地下載最新的節點(包括npm)映像。

希望有幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM