node.js 错误:EACCES:权限被拒绝,mkdir '/usr/local/lib/node_modules/node-sass/build'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49679808/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:45:13  来源:igfitidea点击:

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node-sass/build'

node.jsangularnpm

提问by Rajeev Varshney

I am trying to run angular application and execute ng serve command then show

我正在尝试运行 angular 应用程序并执行 ng serve 命令然后显示

Error: Cannot find module 'node-sass'.

错误:找不到模块“node-sass”

回答by Anirban Sanyal

On Reply :-

回复 :-

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node-sass/build'
Ask Question

Solution :-

解决方案 :-

You need to change ownership of node_modules, because you use sudo npm install -g node-sassso its ownership set to root,

您需要更改 的所有权node_modules,因为您使用sudo npm install -g node-sass它的所有权设置为 root,

To change ownership to current user as group -

要将所有权更改为当前用户作为组 -

sudo chown -R root:YOUR_USERNAME /usr/local/lib/node_modules/

sudo chmod -R 775 /usr/local/lib/node_modules/

And never use sudofor npmrelated query.

永远不要sudo用于npm相关查询。

回答by swati kiran

Try this

尝试这个

sudo npm install -g --unsafe-perm node-sass

须藤 npm install -g --unsafe-perm node-sass

Or this

或这个

sudo npm install -g --unsafe-perm --verbose @angular/cli

须藤 npm install -g --unsafe-perm --verbose @angular/cli

回答by Taimoor Tariq

I am working ionic and have this issue so I solved this by move one folder back and run command.

我正在使用 ionic 并遇到此问题,因此我通过将一个文件夹移回并运行命令来解决此问题。

sudo chmod -R 777 project-directory

sudo chmod -R 777 project-directory

after this npm install node-sass --save

在这之后 npm install node-sass --save

回答by am2505

Run this command

运行这个命令

sudo npm install -g <ModuleName> --unsafe-perm=true --allow-root

回答by Dhruv Singh

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 access problem then:

如果您遇到访问问题,则:

  1. Windows: command prompt in admin mode, then run the above.

  2. Mac: sudo npm install node-sass.

  1. Windows:管理员模式下的命令提示符,然后运行上面的。

  2. Mac:sudo npm install node-sass。

ERROR in Cannot find module 'node-sass'

找不到模块“node-sass”中的错误

https://github.com/sass/node-sass/issues/603

https://github.com/sass/node-sass/issues/603

回答by Santhosh S Kashyap

If you have not added node pakage.json yet try running node init if you already have this npm install node-sass. if both are present and you are using ubuntu try changing permission of the folder using chmod -R path to node module

如果您还没有添加 node pakage.json,如果您已经安装了这个 npm install node-sass,请尝试运行 node init。如果两者都存在并且您正在使用 ubuntu 尝试使用 chmod -R节点模块的路径更改文件夹的权限