最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

如何使用 binsh解决docker相关问题:node

网站源码admin16浏览0评论

如何使用/ bin / sh解决docker相关问题:node

如何使用/ bin / sh解决docker相关问题:node

一天前,我开始独自学习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 [email protected]: The platform "linux" is incompatible with this module. info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... [4/4] Building fresh packages... info Visit 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

我尝试过的事情:

  1. 已安装的节点

D:\docker_stuff\app>node -v v12.16.3;

  1. 已安装npm

D:\docker_stuff\app>npm -v 6.14.4;

  1. 独立运行命令: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 [email protected] node-pre-gyp info using [email protected] | 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.selfmands.<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

  1. 修改了git项目中的package.json文件,在其中我在“ dependencies”下添加了行:{;

  2. 已安装Python。

我感觉package.json文件而不是我的桌面可能有问题,但是我不确定,如果这是问题,我该如何解决?我知道我是菜鸟,但是有人可以为我提供一些指导吗?

回答如下:

["bcrypt": "^3.0.6"需要安装python,并且您在Dockerfile node:12-alpine中使用的映像对于nodejs是非常小的映像。

要么使用ubuntu映像并将python安装到要构建的容器,要么可以使用bcryptjs。

您可以添加或仅运行npm i bcryptjs

[在README.mdbcyptjs上说它将比bcrypt慢30%,但您不必担心python对应用程序的依赖性。

发布评论

评论列表(0)

  1. 暂无评论