尝试安装angular时权限被拒绝

时间:2020-01-14 18:52:10

标签: angular npm

Error: EACCES: permission denied, access \'/Users/gs/.npm-global/lib/node_modules/@angular/cli\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path:
npm ERR!    '/Users/gs/.npm-global/lib/node_modules/@angular/cli' }

The operation was rejected by your operating system.
It is likely you do not have the permissions to access this file as the current user

if you believe this might be a permissions issue, please double-check the
permissions of the file and its containing directories, or try running
the command again as root/Administrator (though this is not recommended).

当我尝试下载的sudo版本但ng在终端中无法识别时,有趣的是。

我的节点是10.16.3,我的npm是6.9.0

这是文件问题还是Mac?

2 个答案:

答案 0 :(得分:1)

您可以找到该问题的解决方案 here
要么
只需按照 here 中的步骤操作即可。

答案 1 :(得分:0)

  1. 在命令行中,在您的主目录中,为全局安装创建一个目录:

    mkdir ~/.npm-global

  2. 配置 npm 以使用新的目录路径:

    npm 配置设置前缀'~/.npm-global'

  3. 在您首选的文本编辑器中,打开或创建一个 ~/.profile 文件并添加以下行:

    导出路径=~/.npm-global/bin:$PATH

  4. 在命令行上,更新您的系统变量:

    源 ~/.profile

  5. 您可以全局安装软件包

    npm install -g @angular/cli