node.js - 更新 Docker 镜像中的 npm

我正在构建一个 Node.js Docker 镜像: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 但仍然无法运行。

docker 文件

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"]

可能是什么原因?我能够使用 Node 运行该应用程序。

我正在运行 Ubuntu 16.04.3 LTS

最佳答案

在 Dockerfile 中,我使用了最新的 alpine 版本 FROM alpine:3.7 并且它有效。

https://stackoverflow.com/questions/47755140/

相关文章:

rest - Django REST 框架 RequestsClient 内容类型

angular - 将 CanActivate() 委托(delegate)给组件

macos - 有没有办法防止 OSX 用数千个 .DS_Store 文件污染我的项目?

python-3.x - 在 XGBoost 中应用增量学习进行分类设置时出错(python)

php - 使用 PHP Trader 函数的问题 : Call to undefined func

amazon-web-services - AWS API 网关响应正文模板映射(foreach)

bazel - 从 bazelrc 选择特定于平台的默认值 --config

python - 如何将 Spyder 设置为默认程序/应用程序以打开 (.py) Python 文

google-chrome-extension - 将 Google Chrome 扩展程序限制为选

vb.net - 字符串中的代码格式 - 我可以将文本设为粗体吗?