[英]Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node-sass/build'
Solution:解决方案:
You need to change the ownership of folder node_modules
, because you use sudo npm install -g node-sass
, so its ownership is set to root.您需要更改文件夹
node_modules
的所有权,因为您使用sudo npm install -g node-sass
,所以它的所有权设置为 root。
To change the ownership to the current user as group -要将所有权更改为当前用户作为组 -
sudo chown -R root:$(whoami) /usr/local/lib/node_modules/
sudo chmod -R 775 /usr/local/lib/node_modules/
And never use sudo
for an npm
-related query.并且永远不要将
sudo
用于与npm
相关的查询。
运行此命令
sudo npm install -g <ModuleName> --unsafe-perm=true --allow-root
Try this尝试这个
sudo npm install -g --unsafe-perm node-sass
sudo npm install -g --unsafe-perm node-sass
Or this或这个
sudo npm install -g --unsafe-perm --verbose @angular/cli
sudo npm install -g --unsafe-perm --verbose @angular/cli
This is due to the user's permission.这是由于用户的许可。 The user from which you are running the command of
npm install
is probably doesn't have permission.您运行
npm install
命令的用户可能没有权限。 So you are getting errors.所以你得到了错误。
For that user just give the permission for that project folder.对于该用户,只需授予该项目文件夹的权限。 In Mac , use the below steps and give read and write permission to the user for that project folder
在Mac中,使用以下步骤并授予用户对该项目文件夹的读取和写入权限
On your Mac, select a disk, folder, or file, and then choose menu File → Get Info .在 Mac 上,选择磁盘、文件夹或文件,然后选择菜单File → Get Info 。
If the information in Sharing & Permissions isn't visible, click the arrow.如果共享和权限中的信息不可见,请单击箭头。
If the lock at the bottom right is locked, click it to unlock the Get Info options, and then enter an administrator name and password.如果右下角的锁被锁定,单击它以解锁“获取信息”选项,然后输入管理员名称和密码。
Click a user or group in the Name column, and then choose a privilege setting from the pop-up menu.单击名称列中的用户或组,然后从弹出菜单中选择权限设置。
Read & Write: Allows a user to open the item and change it.读写:允许用户打开项目并进行更改。
Read-only: This allows a user to open the item but not change its contents.只读:这允许用户打开项目但不能更改其内容。
Write only (Drop Box): Makes a folder into a drop box.只写(投递箱):使文件夹成为投递箱。 Users can copy items to the drop box, but can't open it.
用户可以将项目复制到投递箱,但不能将其打开。 Only the owner of the dropbox can open it.
只有保管箱的所有者才能打开它。
No Access: Blocks all access to the item.无权访问:阻止对该项目的所有访问权。
This helped me to solve the problem.这帮助我解决了问题。
This worked for me -这对我有用 -
sudo chown -R `whoami` ~/.npm
sudo chown -R `whoami` /usr/local/lib/node_modules
If you have not added Node.js pakage.json yet, try running node init
.如果您尚未添加 Node.js pakage.json ,请尝试运行
node init
。 If you already have this, npm install node-sass
.如果你已经有了这个,
npm install node-sass
。
If both are present and you are using Ubuntu , try changing the permission of the folder using chmod -R <path to node module>
.如果两者都存在并且您使用的是Ubuntu ,请尝试使用
chmod -R <path to node module>
更改文件夹的权限。
Try this: npm install node-sass@version试试这个: npm install node-sass@version
If you want the latest, then just try npm install node-sass .如果你想要最新的,那么试试npm install node-sass 。
If you're getting an access problem then:如果您遇到访问问题,那么:
Windows: command prompt in administrator mode, and then run the above. Windows:管理员模式下的命令提示符,然后运行上面的。
Mac:苹果电脑:
sudo npm install node-sass
Make sure you are not in the home directory or other places.确保您不在主目录或其他位置。 You need to go back to root.
你需要回到根目录。
Use this command使用此命令
cd ..
cd ~
Your current location should look like:您当前的位置应如下所示:
~$
After this, run the command to create a project.在此之后,运行命令来创建一个项目。
u need to use a "root" user in your shell,你需要在你的shell中使用“root”用户,
with this command:使用此命令:
sudo su -须藤苏-
then you should enter your password那么你应该输入你的密码
and then try to install the package, i think it will work with any package that you try to install globally然后尝试安装该软件包,我认为它可以与您尝试全局安装的任何软件包一起使用
more info that help me in this website在这个网站上对我有帮助的更多信息
http://www.dark-hamster.com/programming/how-to-solve-error-message-eacces-permission-denied-in-nodejs-application/ http://www.dark-hamster.com/programming/how-to-solve-error-message-eacces-permission-denied-in-nodejs-application/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.