运行命令“ ng add @ angular / pwa”后无法安装Sass v4.10

时间:2018-11-09 04:24:31

标签: node.js sass

我使用命令

建立了一个新项目
"ng new Client --style=scss --routing"

之后,我运行了命令

"ng add @angular/pwa"

然后我尝试运行

"npm start"

它弹出以下消息:

ERROR in ./src/styles.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/styles.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Cannot find module 'node-sass'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.sassLoader (C:\xampp\htdocs\client\node_modules\sass-loader\lib\loader.js:46:72) i 「wdm」: Failed to compile.

我尝试使用命令

"npm install --unsafe-perm=true" 

然后使用

"npm install node-sass"

仍然出现错误消息:

2319 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
2320 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
2321 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin
2321 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any
2321 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: win32
2321 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
2322 warn optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.9.3 (node_modules@angular-devkit\build-angular\node_modules\node-sass):
2323 warn optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.9.3 postinstall: node scripts/build.js
2323 warn optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
2324 verbose optional SKIPPING OPTIONAL DEPENDENCY:
2324 verbose optional Failed at the node-sass@4.9.3 postinstall script.
2324 verbose optional SKIPPING OPTIONAL DEPENDENCY: This is probably not a problem with npm. There is likely additional logging output above.
2325 verbose stack Error: node-sass@4.10.0 postinstall: node scripts/build.js
2325 verbose stack Exit status 1
2325 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
2325 verbose stack at EventEmitter.emit (events.js:182:13)
2325 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
2325 verbose stack at ChildProcess.emit (events.js:182:13)
2325 verbose stack at maybeClose (internal/child_process.js:962:16)
2325 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
2326 verbose pkgid node-sass@4.10.0
2327 verbose cwd C:\xampp\htdocs\client
2328 verbose Windows_NT 6.1.7601
2329 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "node-sass"
2330 verbose node v10.13.0
2331 verbose npm v6.4.1
2332 error code ELIFECYCLE
2333 error errno 1
2334 error node-sass@4.10.0 postinstall: node scripts/build.js
2334 error Exit status 1
2335 error Failed at the node-sass@4.10.0 postinstall script.
2335 error This is probably not a problem with npm. There is likely additional logging output above.
2336 verbose exit [ 1, true ]

有人知道如何解决吗?

3 个答案:

答案 0 :(得分:0)

您应该尝试这个

  

npm重建node-sass

答案 1 :(得分:0)

问题正在解决

npm install --global --production Windows-build-tools,

它将引导节点安装python和所有必要的工具来加载sass

答案 2 :(得分:0)

您可以尝试以下命令

尝试1

 npm install node-sass

尝试2 :删除node_modules文件夹并运行npm install

rm -rf node_modules
run npm install

尝试3

npm install --save node-sass