首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么有时npm安装在mac上不起作用?

问为什么有时npm安装在mac上不起作用?
EN

Stack Overflow用户
提问于 2019-01-12 16:17:39
回答 2查看 28.3K关注 0票数 6

我已经创建了nodejs项目,当我运行命令npm安装时,它出现了一些错误。

同样的项目正在运行于ubuntu系统上,但是当我在mac系统上克隆这段代码并尝试运行npm安装时,它失败了,出现了一些错误。

--我想有一些带有氪星模块的东西,但我不知道确切的原因--请帮助我,谢谢提前

操作系统: MAC

节点: 10.15

国家预防机制:6.0

参见下面的错误:-

代码语言:javascript
复制
WareWolf:mynodeapp$ npm install
> scrypt@6.0.3 preinstall /node_modules/scrypt
> node node-scrypt-preinstall.js

Error: Error: Command failed: ./configure
configure: error: /node_modules/scrypt/scrypt/scrypt-1.2.0':
configure: error: C compiler cannot create executables
See `config.log' for more details

> scrypt@6.0.3 install /node_modules/scrypt
> node-gyp rebuild

gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (/usr/local/Cellar/nvm/0.34.0/versions/node/v10.15.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/Cellar/nvm/0.34.0/versions/node/v10.15.0/bin/node" "/usr/local/Cellar/nvm/0.34.0/versions/node/v10.15.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /node_modules/scrypt
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

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.
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-02-05 18:45:47

您需要删除package-lock.json、.npm和node_modules文件夹。

所需步骤:

代码语言:javascript
复制
npm install npm@latest -g
npm cache clean — force
rm -rf ~/.npm
rm -rf node_modules
rm -f package-lock.json

在npm安装.staging问题中,当您运行npm时,它会创建node_modules文件夹,但是所有模块都会进入一个名为.staging的子文件夹。

票数 12
EN

Stack Overflow用户

发布于 2020-08-17 15:08:18

当我在我的linux机器上启动一个项目时,我发现了同样的问题,我喜欢在Mac上克隆它。

解决方案适用于我:

npm install --no-optional

更多信息:https://stackoverflow.com/a/47071650/2976796

解决这一问题的另一种方法是删除包-lock.json。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54161448

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档