【问题标题】:Permission Denied by System -- mkdir node_modules (MacOS - Monterey)系统拒绝权限 -- mkdir node_modules (MacOS - Monterey)
【发布时间】:2021-12-22 21:15:03
【问题描述】:

我似乎无法解决这个问题... 我已经尝试完全卸载节点并重新安装,清理 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


    【解决方案1】:

    试试这个命令:npm set prefix 'C:\Users\User\AppData\Roaming\npm'

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

    【讨论】:

    • 我有 macOS Monterey
    【解决方案2】:

    已解决:

    我刚刚从官网安装了最新版本的 Node.js。我一直在使用 Home-brew 来升级和安装节点,但显然有些事情没有解决。

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

    【讨论】:

      【解决方案3】:

      这对我的工作原理是sudo npm install -g @angular/cli

      【讨论】:

        猜你喜欢
        • 2021-08-10
        • 2021-07-15
        • 2016-08-24
        • 2013-07-01
        • 2012-08-13
        • 1970-01-01
        • 2019-07-06
        相关资源
        最近更新 更多