node.js - 在基于 Angular 6 的项目中更新 npm 时出现错误

标签 node.js angular npm npm-install

我想使用 cli 命令从 npm 6.1.0 更新新版本的 npm 6.4.0

npm install -g npm

但是我在更新时遇到错误

npm ERR! path /usr/local/lib/node_modules/npm/node_modules/ansi-regex
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm/node_modules/ansi-regex'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm/node_modules/ansi-regex'
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules/npm/node_modules/ansi-regex\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules/npm/node_modules/ansi-regex' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2018-08-23T06_53_24_306Z-debug.log

最佳答案

对于 ubuntu/linux 你必须使用以下命令:

sudo npm install -g npm

关于node.js - 在基于 Angular 6 的项目中更新 npm 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51980123/

相关文章:

node.js - typescript 错误中的字符串枚举

Angular 获取 routerLinkActive 的 ElementRef

node.js - 无法使用 npm 安装 opencv

node.js - Cordova 构建错误 : Use of const in strict mode

javascript - 如何在 Node 上处理来自phonegap的req?

node.js - create-react-app和npm install webpack错误:超出最大调用堆栈大小

node.js - 如何在guard(Resource OwnerGuard)之前执行pipe(Validate ObjectId)?

node.js - 如何转义字符串但不影响nodejs mysql js中的LIKE结果

angular - 模板未应用过滤的日期过滤器(PrimeNG 表)

node.js - 该命令移动到一个单独的包: @webpack-cli/serve