今天使用 npm i docsify-cli -g
安装 node 脚手架工具时,出现以下错误:
andrew@Andrews-MacBook-Pro CSNotes % npm i docsify-cli -g
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/docsify-cli
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/docsify-cli’
npm ERR! [Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/docsify-cli’] {
npm ERR! errno: -13,
npm ERR! code: ‘EACCES’,
npm ERR! syscall: ‘mkdir’,
npm ERR! path: ‘/usr/local/lib/node_modules/docsify-cli’
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/andrew/.npm/_logs/2022-03-12T07_59_19_036Z-debug-0.log
看到 Error: EACCES: permission denied 这句话时,该问题很明显是用户权限不足了。
2 解决方案
解决该权限问题核心思想是提权,但有两种思路:
对文件目录提权
sudo chown -R $USER /usr/local/lib/node_modules
1
对执行用户提权
sudo npm i docsify-cli -g
最终我们顺利安装成功:
————————————————
原文链接:https://blog.csdn.net/adminpd/article/details/123445374
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/275560.html