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

问题描述 投票:0回答:5

我似乎无法解决这个问题...... 我尝试完全卸载节点并重新安装,清理 npm 缓存,重新安装软件包(Angular CLI),运行 sudo chown -R franfonse ../Programming ,但这个问题不断发生。

我尝试运行 ng new my-app 来使用 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.

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

我非常感激。

node.js angular npm angular-cli node-modules
5个回答
0
投票

尝试这个命令:

npm set prefix 'C:\Users\User\AppData\Roaming\npm'

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


0
投票

已解决:

我刚刚从官方网站安装了最新版本的 Node.js。我一直在使用 Home-brew 来升级和安装节点,但显然有些东西不起作用。

通过官网安装Node.js即可。


0
投票

这对我来说是如何工作的

sudo npm install -g @angular/cli


0
投票

运行此命令 sudo npm install -g 打字稿

然后呢


-1
投票

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

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.