我正在尝试将@ vue / cli安装到新的docker映像中。上半年,我上一次这样做是成功的。但是这次发生了奇怪的事情。
这是我的Dockerfile
FROM node:lts-alpine
RUN apk add --no-cache git
RUN yarn global add @vue/cli
当我运行docker image build -t vue:alpine .
时,会收到以下响应:
Sending build context to Docker daemon 4.096kB
Step 1/3 : FROM node:lts-alpine
---> 5d187500daae
Step 2/3 : RUN apk add --no-cache git
---> Using cache
---> 54e50fd9dcb8
Step 3/3 : RUN yarn global add @vue/cli
---> Running in 79e4aa0bf291
yarn global v1.19.1
[1/4] Resolving packages...
error Couldn't find package "function-bind" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
warning @vue/cli > @vue/cli-ui > vue-cli-plugin-apollo > nodemon > chokidar > fsevents@1.2.9: One of your dependencies needs to upgrade to fsevents v2: 1) Proper nodejs v10+ support 2) No more fetching
binaries from AWS, smaller package size
Error: Couldn't find package "arr-diff" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "array-unique" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "array-unique" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "array-unique" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "arr-diff" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "ajv" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "function-bind" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "array-unique" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "function-bind" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "function-bind" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "function-bind" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "json5" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "statuses" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "statuses" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "statuses" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "for-in" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "statuses" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
at Generator.next (<anonymous>)
at step (/opt/yarn-v1.19.1/lib/cli.js:304:30)
at /opt/yarn-v1.19.1/lib/cli.js:315:13
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "function-bind" on the "npm" registry.
at MessageError.ExtendableBuiltin (/opt/yarn-v1.19.1/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.19.1/lib/cli.js:750:123)
at NpmResolver.<anonymous> (/opt/yarn-v1.19.1/lib/cli.js:50683:15)
我试图在npmjs.com上找到其中一些软件包,它们还可以。
这样看来,某事阻止yarn
连接到npm repo。
有人有类似的问题吗?如何解决?
小更新: 我已经用npm(Dockerfile)尝试了类似的事情:
FROM node:lts-alpine
RUN apk add --no-cache git
RUN npm install -g @vue/cli
几分钟后,我得到了:
Sending build context to Docker daemon 4.096kB
Step 1/3 : FROM node:lts-alpine
---> 5d187500daae
Step 2/3 : RUN apk add --no-cache git
---> Using cache
---> 54e50fd9dcb8
Step 3/3 : RUN npm install -g @vue/cli
---> Running in 9c8e21b3fcc7
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/statuses
npm ERR! 404
npm ERR! 404 'statuses@>= 1.5.0 < 2' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'http-errors'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-11-16T18_48_54_942Z-debug.log
The command '/bin/sh -c npm install -g @vue/cli' returned a non-zero code: 1
答案 0 :(得分:1)
所以我弄清楚了,问题是由npm
图像提供的yarn
(有时是node
)。当前图像node:13.1.0-alpine
包含npm version 6.12.0
这是我解决的方法:
FROM node:lts-alpine
RUN apk add --no-cache curl
RUN curl -L https://www.npmjs.com/install.sh | sh
RUN npm -v
该Dockerfile中使用的脚本由npm本身提供,并且它将npm的较新版本安装到映像中。 npm version 6.13.1
比起我刚刚构建它,并使用它代替原始图像。
docker build -t node-updated .
docker run node-updated npm install -g @vue/cli
尽管如此,它不能解决yarn
的问题。
我很确定这是node
图片的暂时问题,因为它将很快更新。希望有人会发现它有用。
答案 1 :(得分:0)
默认情况下不安装 Yarn。 通过在 Dockerfile 中添加以下行,您可以安装 yarn。
RUN apk add yarn
apk
命令类似于 apt-get
或 yum
,但适用于高山分布。
yarn 安装好后,可以添加以下行来安装 vue-cli 和 vue-cli-service。就我而言,我需要两者。
RUN yarn global add @vue/cli @vue/cli-service-global