权限被系统拒绝--mkdir node_modules(MacOS-Monterey)



我似乎无法解决这个问题。。。我已经尝试过完全卸载node并重新安装,清理npm缓存,重新安装包(Angular CLI(,运行sudo chown-R franfonse/编程,但这个问题一直在发生。

我试着运行ng new我的应用程序,用Angular CLI创建一个新项目,这就是我一直得到的:

npm ERR! syscall mkdir
npm ERR! path /Users/franfonse/Desktop/Programming/my-app/node_modules
npm ERR! errno -1
npm ERR! Error: EPERM: operation not permitted, mkdir '/Users/franfonse/Desktop/Programming/my-app/node_modules'
npm ERR!  [Error: EPERM: operation not permitted, mkdir '/Users/franfonse/Desktop/Programming/my-app/node_modules'] {
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/Users/franfonse/Desktop/Programming/my-app/node_modules'
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/franfonse/.npm/_logs/2021-11-10T08_54_24_926Z-debug.log
✖ Package install failed, see above.
The Schematic workflow failed. See above.

有人知道如何解决这个问题吗?

我会非常感激的。

尝试此命令:npm set prefix 'C:UsersUserAppDataRoamingnpm'

如果您已经设置了该值,请在删除前缀后再次运行上述命令。

已解决:

我刚刚从官方网站安装了Node.js的最新版本。我一直在使用Homebrew来升级和安装节点,但很明显,有些事情并没有解决。

只需通过官方网站安装Node.js即可。

这对我来说是如何工作的sudo npm install -g @angular/cli

运行此命令sudo npm安装-g typescript

当您试图安装任何npm软件包,但由于权限问题而无法安装时,请查看此视频以获得解决方案。

使用此命令可以启用对各个npm安装位置的权限。

sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

上面的命令会要求你输入密码,所以你需要使用我们用来登录mac的系统密码。

最新更新