在 macOS mojave 上安装 angular/cli 时出错 - node-pre-gyp

2024-01-23

我格式化了 imac 并删除了 HD 上的所有文件。但是,当我安装 Angular cli 7 时,终端控制台显示此错误日志。

环境

macOS:莫哈韦沙漠 10.14.2 节点:v10.15 npm:6.4.1


控制台错误

miguels-imac:~ makito$ sudo npm install -g @angular/cli
/usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng

> [email protected] /cdn-cgi/l/email-protection install 
/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents
> node install

node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for [email protected] /cdn-cgi/l/email-protection 
and [email protected] /cdn-cgi/l/email-protection (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib'
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/build'
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/Cellar/node@10/10.15.0/bin/node" "/usr/local/Cellar/node@10/10.15.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /usr/local/lib/node_modules/@angular/cli/node_modules/fsevents
gyp ERR! node -v v10.15.0
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 '/usr/local/Cellar/node@10/10.15.0/bin/node /usr/local/Cellar/node@10/10.15.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:962:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
node-pre-gyp ERR! System Darwin 18.2.0
node-pre-gyp ERR! command "/usr/local/Cellar/node@10/10.15.0/bin/node" "/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/@angular/cli/node_modules/fsevents
node-pre-gyp ERR! node -v v10.15.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/Cellar/node@10/10.15.0/bin/node /usr/local/Cellar/node@10/10.15.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] /cdn-cgi/l/email-protection (node_modules/@angular/cli/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] /cdn-cgi/l/email-protection install: `node install`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

+ @angular/[email protected] /cdn-cgi/l/email-protection
added 294 packages from 178 contributors in 20.637s

如果我显示全局依赖项,我有@angular/cli...那么,为什么会出现这个错误?我做错了什么?

在 stackOverflow 上搜索,我决定安装node-pre-gyp,并安装 xCode。但是,没有任何改变。


好吧,我这样做了,它对我有用。

  1. rm -rf /usr/local/lib/node_modules
  2. 酿造卸载节点
  3. brew 安装节点 --without-npm
  4. echo prefix=~/.npm-packages >> ~/.npmrc
  5. curl -L https://www.npmjs.com/install.sh https://www.npmjs.com/install.sh | sh
  6. 将以下行添加到您的 ~/.bash_profile (导出 PATH="$HOME/.npm-packages/bin:$PATH")

  7. 卸载当前的@angular/cli (sudo npm uninstall -g @angular/cli)

  8. npm 缓存清理 --force / npm 缓存验证
  9. xcode-选择--安装
  10. npm install -g 节点 gyp
  11. npm install -g @angular/cli (不带 sudo)。

让我知道它是否有效

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 macOS mojave 上安装 angular/cli 时出错 - node-pre-gyp 的相关文章

随机推荐