ZFSYS

mac使用npm安装包,报没有权限

178

执行代码

npm install -g yo generator-code

时报错

(base) zf@192 test % npm install -g yo generator-code
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/generator-code
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/generator-code'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/generator-code'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/generator-code'
npm ERR! }
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.

npm ERR! A complete log of this run can be found in: npm ERR!     /Users/zf/.npm/_logs/2022-06-09T03_50_43_247Z-debug-0.log

一看是权限问题,执行

 sudo chown -R $USER /usr/local/lib/node_modules


这时又有报错

(base) zf@192 test % npm install -g yo generator-code
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/yo/lib/cli.js
npm ERR! dest /usr/local/bin/yo
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/yo/lib/cli.js' -> '/usr/local/bin/yo'
npm ERR!  [Error: EACCES: permission denied, symlink '../lib/node_modules/yo/lib/cli.js' -> '/usr/local/bin/yo'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../lib/node_modules/yo/lib/cli.js',
npm ERR!   dest: '/usr/local/bin/yo'
npm ERR! }
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.

npm ERR! A complete log of this run can be found in: npm ERR!     /Users/zf/.npm/_logs/2022-06-09T03_53_45_762Z-debug-0.log


执行  sudo chown -R $USER /usr/local/bin

这时就可以安装了

  • 没有任何评论
最新帖子
[站长推荐] 一些站长/创业者使用的工具推荐 593
HTML+JS 全选与取消全选功能 546
子枫内容系统更新记录 449
有没有人做百度小程序啊 447
PHP 按照指定数量切割字符串 393
php composer更换国内源 375
a链接一键安装ios应用 373
composer 报错SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify 348
layui table 的宽度超出自动隐藏 345
怎么克服拖延症呀 339
最近热帖
[站长推荐] 一些站长/创业者使用的工具推荐 593
HTML+JS 全选与取消全选功能 546
子枫内容系统更新记录 449
有没有人做百度小程序啊 447
PHP 按照指定数量切割字符串 393
php composer更换国内源 375
a链接一键安装ios应用 373
composer 报错SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify 348
layui table 的宽度超出自动隐藏 345
怎么克服拖延症呀 339
近期热议
开始使用 161