安装angular-cli时出现错误"EACCES root access node-gyp folder"是由于您在执行npm install命令时没有足够的权限访问node-gyp文件夹。以下是解决此问题的几种方法:
使用sudo命令:
sudo npm install -g @angular/cli
更改npm的默认全局安装目录:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
source ~/.profile
npm install -g @angular/cli
使用nvm(Node Version Manager)安装node和angular-cli:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.36.0/install.sh | bash
source ~/.bashrc
nvm install node
npm install -g @angular/cli
如果您使用的是Windows操作系统,可以尝试使用PowerShell以管理员身份运行命令提示符或使用Git Bash。
请注意,在尝试这些解决方法之前,请确保您已经安装了最新版本的Node.js和npm。