一天前,我开始自学Docker。所以我将应用下载到我的 Windows 10 桌面,并开始学习他们通过应用推荐的教程。有一次,他们要求我创建一个包含以下内容的 docker 文件:
FROM node:12-alpine
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "/app/src/index.js"]
我对路径所做的事情:D:\docker_stuff\app
名称为“Dockerfile”,没有扩展名。接下来他们要求我运行这个命令“docker build -t getting-started”。这是我遇到问题的地方,因为该命令会引发以下错误:
D:\docker_stuff\app>docker build -t getting-started .
Sending build context to Docker daemon 4.673MB
Step 1/5 : FROM node:12-alpine
---> 7a48db49edbf
Step 2/5 : WORKDIR D:\docker_stuff\app
---> Using cache
---> 44ba6501de00
Step 3/5 : COPY . .
---> 44164775d408
Step 4/5 : RUN yarn install --production
---> Running in 5df554d6bac8
yarn install v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error /D:docker_stuffapp/node_modules/bcrypt: Command failed.
Exit code: 127
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: /D:docker_stuffapp/node_modules/bcrypt
Output:
/bin/sh: node-pre-gyp: not found
我尝试了什么:
- 安装节点
D:\docker_stuff\app>node -v
v12.16.3;
- 安装 npm
D:\docker_stuff\app>npm -v
6.14.4;
- 独立运行命令: node-pre-gyp install --fallback-to-build 引发更多问题:
D:\docker_stuff\app>node-pre-gyp install --fallback-to-build
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.14.0
node-pre-gyp info using node@12.16.3 | win32 | x64
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp ERR! install error
node-pre-gyp ERR! stack Error: 101-app package.json is not node-pre-gyp ready:
node-pre-gyp ERR! stack package.json must declare these properties:
node-pre-gyp ERR! stack binary.module_name
node-pre-gyp ERR! stack binary.module_path
node-pre-gyp ERR! stack binary.host
node-pre-gyp ERR! stack at validate_config (C:\Users\KahnTrevor\AppData\Roaming\npm\node_modules\node-pre-gyp\lib\util\versioning.js:220:15)
node-pre-gyp ERR! stack at Object.module.exports.evaluate (C:\Users\KahnTrevor\AppData\Roaming\npm\node_modules\node-pre-gyp\lib\util\versioning.js:279:5)
node-pre-gyp ERR! stack at install (C:\Users\KahnTrevor\AppData\Roaming\npm\node_modules\node-pre-gyp\lib\install.js:241:31)
node-pre-gyp ERR! stack at Object.self.commands.<computed> [as install] (C:\Users\KahnTrevor\AppData\Roaming\npm\node_modules\node-pre-gyp\lib\node-pre-gyp.js:52:37)
node-pre-gyp ERR! stack at run (C:\Users\KahnTrevor\AppData\Roaming\npm\node_modules\node-pre-gyp\bin\node-pre-gyp:82:30)
node-pre-gyp ERR! stack at Object.<anonymous> (C:\Users\KahnTrevor\AppData\Roaming\npm\node_modules\node-pre-gyp\bin\node-pre-gyp:134:1)
node-pre-gyp ERR! stack at Module._compile (internal/modules/cjs/loader.js:1133:30)
node-pre-gyp ERR! stack at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
node-pre-gyp ERR! stack at Module.load (internal/modules/cjs/loader.js:977:32)
node-pre-gyp ERR! stack at Function.Module._load (internal/modules/cjs/loader.js:877:14)
node-pre-gyp ERR! System Windows_NT 10.0.18363
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\KahnTrevor\\AppData\\Roaming\\npm\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd D:\docker_stuff\app
node-pre-gyp ERR! node -v v12.16.3
node-pre-gyp ERR! node-pre-gyp -v v0.14.0
node-pre-gyp ERR! not ok
101-app package.json is not node-pre-gyp ready:
package.json must declare these properties:
binary.module_name
binary.module_path
binary.host
修改了 git 项目中的 package.json 文件,我在 "dependencies" 下添加了行 <"bcrypt": "^3.0.6",>: { ;
Python 已安装。
我觉得 package.json 文件而不是我的桌面可能存在问题,但我不确定,如果这是问题,我该如何解决?我知道我是菜鸟,但谁能给我一些指导?