gyp WARN EACCES尝试安装angular / cli

时间:2018-02-22 09:59:50

标签: angular ubuntu npm

我正在使用Ubuntu 17.04并且我安装了节点8.9.4LTS。当我尝试使用npm安装angular / cli时,我在循环中得到了这个错误。

gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.9.4"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp"
gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
gyp verb command install [ '8.9.4' ]
gyp verb install input version string "8.9.4"
gyp verb install installing version: 8.9.4
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 8.9.4
gyp verb ensuring nodedir is created /usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.9.4

以下是错误的屏幕截图:

enter image description here

我尝试使用此命令进行安装: sudo npm install -g @ angular / cli

如何安装角度CLI?

修正了!!!:

我不知道为什么,但我已经尝试再次安装angular / cli并且它有效!以前我什么也没做!我不知道发生了什么!!!

1 个答案:

答案 0 :(得分:1)

这个问题本身就解决了。但是我希望与您分享一个简短的解释,以后可能对您有所帮助。

您似乎遇到了权限问题。如果您正在安装<div class="centered"> <marquee direction="left"> <p>Industrial IoT</p><span><a href="images/pdf/2018/Cell Tower Monitoring.pdf">Asset Management</a></span> </marquee> </div> <div class="centered"> <marquee direction="left" scrolldelay="20"> <p>Industrial IoT</p><span><a href="images/pdf/2018/Cell Tower Monitoring.pdf">Cell Tower Monitoring</a></span> </marquee> </div> <div class="centered"> <marquee direction="left" scrolldelay="30"> <p>Industrial IoT</p><span><a href="images/pdf/2018/Remote Monitoring Smart factory.pdf">Remote Monitoring Smart factory</a></span> </marquee> </div> <div class="centered"> <marquee direction="left" scrolldelay="40"> <p>Engineering Analytics</p><span><a href="images/pdf/Climate Control for Networking Laboratory.pdf">Climate Control for Networking Laboratory</a></span> </marquee> </div> <div class="centered"> <marquee direction="left" scrolldelay="50"> <p>SDN/NFV</p><span><a href="images/pdf/2018/Building SDN Compatibility in Legacy Devices for OEM.pdf">Building SDN Compatibility in Legacy Devices for OEM</a></span> </marquee> </div> <div class="centered"> <marquee direction="left" scrolldelay="60"> <p>SDN/NFV</p><span><a href="images/pdf/2018/Building Software Licensing Support for Virtual Network Functions (VNF).pdf">Building Software Licensing Support for Virtual Network Functions (VNF)</a></span> </marquee> </div> <div class="centered"> <marquee direction="left" scrolldelay="70"> <p>SDN/NFV</p><span><a href="images/pdf/2018/Building a Network Access Control (NAC) Capable SDN Controller.pdf">Building a Network Access Control (NAC) Capable SDN Controller</a></span> </marquee> </div> <div class="centered"> <marquee direction="left" scrolldelay="80"> <p>SDN/NFV</p><span><a href="images/pdf/Building a SD-WAN Solution for IoT Gateway.pdf">Building SD-WAN Solution for IoT Gateway</a></span> </marquee> </div> <div class="centered"> <marquee direction="left" scrolldelay="90"> <p>SDN/NFV</p><span><a href="images/pdf/2018/Building a SDN Controller with Zero Touch.pdf">Building a SDN Controller with Zero Touch Provisioning Capabilities</a></span> </marquee> </div> <div class="centered"> <marquee direction="left" scrolldelay="10"> <p>SDN/NFV</p><span><a href="images/pdf/2018/Enabling Network Function Virtualisation (NFV) Capabilities for OEM (1).pdf">Enabling Network Function Virtualisation (NFV) Capabilities for OEM</a></span> </marquee> </div> ,那么在尝试全局安装软件包时可能会出现npm-packages错误。这意味着您无权写入EACCES用于存储全局包和命令的目录。

您可以通过运行命令来更改目录权限:npmsudo chmod u+x -R 775 ~/.npm,或者您可以使用sudo chown $USER -R ~/.npm运行任何npm命令,这样就可以解决您的问题。

如果要在本地安装sudo,那么您应该在本地项目目录中,并且可以尝试运行npm-package命令来安装所需的包。使用sudo npm install <pkg-name>的目的是它将更改您的所有者权限,以便您可以授权当前用户运行sudo命令。

我建议你看看https://docs.npmjs.com/getting-started/fixing-npm-permissions