【问题标题】:can't install @angular/cli properly无法正确安装@angular/cli
【发布时间】:2018-04-11 12:56:13
【问题描述】:

npm install 崩溃了:

sudo npm install -g @angular/cli

我尝试用 cash clean 卸载它几次,然后用 @angular/cli 重新安装它,它总是崩溃。

dmitri@dmitri-thinkpad-e570:~$ sudo npm install -g @angular/cli
npm WARN registry Using stale data from https://registry.npmjs.org/ because the host is inaccessible -- are you offline?
npm WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/bn.js-a9de3ac3/lib/bn.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/async-test.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/webpack-dev-server-4b3dbb2d/bin/webpack-dev-server.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/webapis-media-query.min.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/webapis-notification.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/webapis-notification.min.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/ajv-keywords-e7de9002/keywords/dotjs/README.md'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/webapis-rtc-peer-connection.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/ajv-keywords-e7de9002/keywords/dotjs/_formatLimit.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/webapis-media-query.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/ajv-keywords-e7de9002/keywords/dotjs/patternRequired.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/webapis-shadydom.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging//src/serializers/dts.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/ajv-keywords-e7de9002/keywords/dotjs/switch.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/webapis-shadydom.min.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging//src/serializers/json.js'
npm WARN tar ENOENT: no such file or directory, lstat '/usr/local/lib/node_modules/.staging/ajv-keywords-e7de9002/keywords/dot'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/wtf.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging//src/serializers/dts.d.ts'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/wtf.min.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging//src/serializers/dts.js.map'
npm WARN tar ENOENT: no such file or directory, lstat '/usr/local/lib/node_modules/.staging/ajv-keywords-e7de9002/keywords/dot'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/zone-bluebird.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging//src/serializers/json.d.ts'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/task-tracking.min.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging//src/serializers/json.js.map'
npm WARN tar ENOENT: no such file or directory, lstat '/usr/local/lib/node_modules/.staging/ajv-keywords-e7de9002/keywords/dot'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/zone-bluebird.min.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/task-tracking.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/zone-error.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/sync-test.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/bluebird-57ade097/js/browser/bluebird.min.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/zone-error.min.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/proxy.min.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/zone.js-071eb577/dist/zone-mix.js'
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/caniuse-db-e3ba940e/.editorconfig'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.5.3 (node_modules//node_modules/node-sass):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: Cannot cd into '/usr/local/lib/node_modules/.staging/node-sass-d131eca4'

npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/url-loader/-/url-loader-0.6.2.tgz failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR! /home/dmitri/.npm/_logs/2017-10-30T12_53_53_219Z-debug.log
supporting information:

【问题讨论】:

标签: node.js ubuntu npm angular-cli npm-install


【解决方案1】:

彻底删除你的 node_modules 目录,然后再次运行 sudo npm install

如果需要的话你可以试试这个:

要在本地安装 @angular/cli,请运行 npm install @angular/cli --save,而要在全局安装它,请运行 npm install -g @angular/cli

但如果它需要 root 访问权限,那么您必须包含 sudo,这将是 sudo npm install -g @angular/cli

或视情况检查您的网络连接(互联网)。

希望对你有帮助

【讨论】:

  • 我想安装@angular/cli(不是angular-cli)。
  • 谢谢我已经解决了这个问题。很奇怪,网络问题。在其他 WiFi 上它很简单,因为它必须是。谢谢
  • 很高兴听到这个消息!
猜你喜欢
  • 2017-01-25
  • 2018-06-13
  • 2021-04-20
  • 2021-09-11
  • 2017-08-22
  • 2017-03-23
  • 2019-10-24
相关资源
最近更新 更多