当我尝试npm install -g @angular/cli
时出现错误:
npm ERR! path /usr/lib/node_modules/@angular
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/@angular'
npm ERR! { Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/@angular'
npm ERR! stack: 'Error: EACCES: permission denied, mkdir \'/usr/lib/node_modules/@angular\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/lib/node_modules/@angular' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/my_name/.npm/_logs/2017-07-15T16_09_19_320Z-debug.log
Therofore我跑sudo npm install -g @angular/cli
但我收到错误:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: acorn@4.0.13 (node_modules/acorn-dynamic-import/node_modules/acorn):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: request to https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org:443
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @types/serve-static@1.7.31 (node_modules/@types/serve-static):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: request to https://registry.npmjs.org/@types/serve-static/-/serve-static-1.7.31.tgz failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org:443
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: acorn@5.1.1 (node_modules/acorn):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: request to https://registry.npmjs.org/acorn/-/acorn-5.1.1.tgz failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org:443
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @types/minimatch@2.0.29 (node_modules/@types/minimatch):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: request to https://registry.npmjs.org/@types/minimatch/-/minimatch-2.0.29.tgz failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org:443
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: uuid@3.1.0 (node_modules/uuid):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime '/home/my_name/dev/angular/angular-cli/node_modules/.staging/uuid-d533788a/lib/bytesToUuid.js'
npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/@types/source-map/-/source-map-0.5.0.tgz failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org:443
npm ERR! A complete log of this run can be found in:
npm ERR! /home/my_name/.npm/_logs/2017-07-15T16_09_46_119Z-debug.log
为什么我不能这样做。最近没有任何作用。
我使用Ubuntu 16.04 lts
答案 0 :(得分:2)
运行命令sudo rm -rf ~/.npm
以清除npm缓存。然后尝试再次使用sudo npm i @angular/cli
运行命令