javascript - `npm install npm` 给出 gyp ERR 和 npm ERR

标签 javascript node.js npm npm-install gyp

为什么在执行 sudo npm install npm 时会出现这个奇怪的错误?我有时在尝试安装其他模块时也会得到它!

错误:

> scrypt@6.0.3 preinstall /home/user/code/project/api_v0.8/node_modules/scrypt
> node node-scrypt-preinstall.js


> scrypt@6.0.3 install /home/user/code/project/api_v0.8/node_modules/scrypt
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/user/code/project/api_v0.8/node_modules/scrypt/build'
gyp ERR! System Linux 4.20.0-042000-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/user/code/project/api_v0.8/node_modules/scrypt
gyp ERR! node -v v9.11.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN api_v0.8@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt@6.0.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the scrypt@6.0.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我该怎么做才能全新安装我的软件包?

最佳答案

要解决此问题,请安装 Node 版本管理器:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

用户 Node v8.15.0:

nvm install 8.15.0
nvm use 8.15.0

关于javascript - `npm install npm` 给出 gyp ERR 和 npm ERR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54040720/

相关文章:

node.js - NPM 模块引用不适用于 Mongoose

javascript - Jasmine:如何在我的自定义匹配器中重用其他匹配器

node.js - 惯用的 Node 错误处理

javascript - Lodash 类似导入实现

node.js - ELOOP : too many symbolic links encountered

node.js - Google云平台中的Websocket

javascript - 如何拦截window.location变化

Javascript 表单验证不为空或没有空格

javascript - 主干保存嵌套集合

javascript - Promises 和 Nodejs 的具体示例(无解决方案)