简体   繁体   English

无法在角度项目中安装Node-Sass

[英]Can't install node-sass inside angular project

I've cloned a repo from an existing Angular project and executed sudo npm install within the project. 我已经从现有的Angular项目中克隆了一个仓库,并在该项目中执行了sudo npm install

All packages were installed so far, but the packet node-sass still causes problems. 到目前为止,所有软件包都已安装,但是数据包节点萨斯仍然会引起问题。

After the installation process of sudo npm install is finished I get the following error message: sudo npm install的安装过程完成后,出现以下错误消息:

gyp ERR! 糟糕! configure error gyp ERR! 配置错误gyp ERR! stack Error: EACCES: permission denied, mkdir '/ Users / oek1wa3 / Documents / CODEHAN / management / node_modules / node-sass / build' gyp ERR! 堆栈错误:EACCES:权限被拒绝,mkdir'/用户/ oek1wa3 /文档/ CODEHAN /管理/ node_modules / node-sass / build'gyp ERR! System Darwin 18.6.0 gyp ERR! 系统达尔文18.6.0 gyp错误! command "/ usr / local / bin / node" "/Users/oek1wa3/Documents/CODEHAN/management/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext = "" --libsass_cflags = "" --libsass_ldflags = "" --libsass_library = " gyp ERR! 命令“ /usr/local/bin/node""/Users/oek1wa3/Documents/CODEHAN/management/node_modules/node-gyp/bin/node-gyp.js”“重建”“ --verbose”“ --libsass_ext = “” --libsass_cflags =“” --libsass_ldflags =“” --libsass_library =“ gyp错误! cwd / Users / oek1wa3 / Documents / CODEHAN / management / node_modules / node-sass gyp ERR! cwd /用户/ oek1wa3 /文档/ CODEHAN /管理/ node_modules / node-sass gyp错误! node -v v11.10.0 gyp ERR! 节点-v v11.10.0 gyp ERR! node-gyp -v v3.8.0 gyp ERR! node-gyp -v v3.8.0 gyp错误! not ok 不好

If I try to compile the project also an error appears and displays this message (only a section): 如果我尝试编译项目,也会出现错误并显示此消息(仅一部分):

 at Object.Module._extensions..js (internal / modules / cjs / loader.js: 749: 10) at Module.load (internal / modules / cjs / loader.js: 630: 32) at tryModuleLoad (internal / modules / cjs / loader.js: 570: 12) at Function.Module._load (internal / modules / cjs / loader.js: 562: 3) at Module.require (internal / modules / cjs / loader.js: 667: 17) at require (internal / modules / cjs / helpers.js: 20: 18) at Object. <anonymous> (/Users/oek1wa3/Documents/CODEHAN/management/node_modules/sass-loader/lib/loader.js:3:14) at Module._compile (internal / modules / cjs / loader.js: 738: 30) ERROR in ./src/app/app.component.scss 

I've already tried to delete the node_modules folder and the package-lock.json file and run the installation again. 我已经尝试删除node_modules文件夹和package-lock.json文件,然后再次运行安装。 Unfortunately without success. 不幸的是没有成功。 I could not find anything else on the net that fixed this problem. 我在网上找不到其他解决此问题的方法。

The package.json contains the following versions of relevant packages: package.json包含以下版本的相关软件包:

"node-sass": "^4.7.2",
"sass-loader": "^6.0.5",
"@angular/cli": "^7.3.9",
"@angular/core": "7.2.0",

My current npm version: 6.7.0 | 我当前的npm版本: 6.7.0 | My current node version: v11.10.0 我当前的节点版本: v11.10.0

I'm using a MacBook Pro with macOS Mojave version 10.14.5. 我使用的是MacOS Mojave 10.14.5版的MacBook Pro。

How can I fix this problem for my project to compiled again? 如何解决此问题,以便我的项目再次编译?

try this one: 试试这个:

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

It worked for me 对我有用

Also Check this 也检查一下

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM