如何修复“无法在./src/global.scss中编译”

时间:2019-02-01 07:33:40

标签: angular ionic-framework node-sass

我已经在ionic v4中创建了项目,但是在./src/global.scss中遇到了错误,请参见下面的错误

>ERROR in ./src/global.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/global.scss)
[ng] Module build failed (from ./node_modules/sass-loader/lib/loader.js):
[ng] Error: Cannot find module 'node-sass'
[ng]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
[ng]     at Function.Module._load (internal/modules/cjs/loader.js:507:25)
[ng]     at Module.require (internal/modules/cjs/loader.js:637:17)
[ng]     at require (internal/modules/cjs/helpers.js:22:18)
[ng]     at Object.sassLoader (/home/manish/newionic_workspace/latest100days/node_modules/sass-loader/lib/loader.js:46:72)
[ng] ERROR in ./src/theme/variables.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/theme/variables.scss)
[ng] Module build failed (from ./node_modules/sass-loader/lib/loader.js):
[ng] Error: Cannot find module 'node-sass'
[ng]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
[ng]     at Function.Module._load (internal/modules/cjs/loader.js:507:25)
[ng]     at Module.require (internal/modules/cjs/loader.js:637:17)
[ng]     at require (internal/modules/cjs/helpers.js:22:18)
[ng]     at Object.sassLoader (/home/manish/newionic_workspace
/latest100days/node_modules/sass-loader/lib/loader.js:46:72)

我也使用了rebuild命令

npm rebuild node-sass 

但是不起作用

2 个答案:

答案 0 :(得分:1)

使用npm install --save-dev node-sassnpm rebuild node-sass --force

答案 1 :(得分:1)

您必须先授予全局权限,然后在开始时添加sudo。

sudo npm i node-sass

希望这对您也有用!