【问题标题】:Couldn't install npm packages - bcrypt@3.0.6 install: `node-pre-gyp install --fallback-to-build` in Ubuntu 18.04无法安装 npm 包 - bcrypt@3.0.6 install: `node-pre-gyp install --fallback-to-build` in Ubuntu 18.04
【发布时间】:2019-12-22 20:52:42
【问题描述】:

我正在尝试 npm install(注意:通过 lerna bootstrap)在 Ubuntu 18.04 中安装一个项目。我遇到一个错误(npm ERR!bcrypt@3.0.6 install:node-pre-gyp install --fallback-to-build ) 并且无法前进。

我也尝试过安装 node-gyp、node-pre-gyp 和 apt-get build-essentials,相信这可能是因为 C++ 编译问题,但没有运气。

版本: 节点:v10.16.0 NPM:6.9.0

ren@renish:~/Src/company$ sudo npm run bootstrap
npm WARN lifecycle The node binary used for scripts is /bin/node but npm is using /snap/node/2485/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> company@ bootstrap /home/ren/Src/company
> npm install && npx lerna bootstrap

npm WARN company@ No repository field.
npm WARN company@ No license field.

audited 43804 packages in 3.726s
found 41 high severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details
lerna notice cli v3.15.0
lerna info Bootstrapping 7 packages
lerna info Installing external dependencies
lerna ERR! npm install exited 1 in 'company_api'
lerna ERR! npm install stdout:

> bcrypt@3.0.6 install /home/ren/Src/company/packages/api/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

Failed to execute '/snap/node/2485/bin/node /snap/node/2485/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/ren/Src/company/packages/api/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/home/ren/Src/company/packages/api/node_modules/bcrypt/lib/binding --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)

lerna ERR! npm install stderr:
node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Pre-built binaries not installable for bcrypt@3.0.6 and node@10.16.1 (node-v64 ABI, glibc) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/home/ren/Src/company/packages/api/node_modules/bcrypt/lib' 
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/ren/Src/company/packages/api/node_modules/bcrypt/build'
gyp ERR! System Linux 5.0.0-25-generic
gyp ERR! command "/snap/node/2485/bin/node" "/snap/node/2485/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/home/ren/Src/company/packages/api/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/home/ren/Src/company/packages/api/node_modules/bcrypt/lib/binding" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64"
gyp ERR! cwd /home/ren/Src/company/packages/api/node_modules/bcrypt
gyp ERR! node -v v10.16.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/snap/node/2485/bin/node /snap/node/2485/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/ren/Src/company/packages/api/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/home/ren/Src/company/packages/api/node_modules/bcrypt/lib/binding --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/ren/Src/company/packages/api/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:982:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Linux 5.0.0-25-generic
node-pre-gyp ERR! command "/snap/node/2485/bin/node" "/home/ren/Src/company/packages/api/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/ren/Src/company/packages/api/node_modules/bcrypt
node-pre-gyp ERR! node -v v10.16.1
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bcrypt@3.0.6 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the bcrypt@3.0.6 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ren/.npm/_logs/2019-08-16T13_52_33_286Z-debug.log

lerna ERR! npm install exited 1 in 'company_api'
lerna WARN complete Waiting for 1 child process to exit. CTRL-C to exit immediately.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! company@ bootstrap: `npm install && npx lerna bootstrap`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the company@ bootstrap script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ren/.npm/_logs/2019-08-16T13_52_33_951Z-debug.log

有人能解释一下吗?

【问题讨论】:

  • 看起来您遇到了一个简单的文件权限问题。这就是 EACCESS 错误告诉你的内容。
  • 这不是文件权限问题(我给 sudo chmod 777 -R node_modules/ 并在命令上使用 sudo)。可能是节点版本问题。请检查版本 8.11 和纱线,让我知道问题仍然存在
  • 是的@Ashok,这似乎不是权限问题。我也试过了,没有运气。相同的代码在具有相同节点和 npm 版本的不同系统(ubuntu 和 mac)中运行良好。

标签: javascript node.js ubuntu npm lerna


【解决方案1】:

嗯,这是一个版本,并且访问问题在错误消息中非常清楚。更改权限是一步,但您似乎需要更新您的:

节点

gyp ERR! node -v v10.16.1 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok

还有你的系统 linux 版本出于某种原因: gyp ERR! System Linux 5.0.0-25-generic

【讨论】:

  • 我们应该使用哪个版本的节点和 npm。你能解释一下吗?
猜你喜欢
  • 2018-08-05
  • 1970-01-01
  • 2020-08-03
  • 2021-01-13
  • 2020-02-05
  • 2018-12-08
  • 2016-02-01
  • 2016-02-12
  • 2020-01-17
相关资源
最近更新 更多