简体   繁体   English

运行 angular 项目会导致 node-sass 出错

[英]running angular project gives error for node-sass

I am running a anglar project in my local environment.我正在本地环境中运行一个 anglar 项目。 with below specified vesions.具有以下指定的版本。 and i cannot run project and get the errors below: npm version : 6.9.0 Angular CLI: 7.3.9 Node: 10.16.0 OS: win32 x64我无法运行项目并收到以下错误:npm 版本:6.9.0 Angular CLI:7.3.9 节点:10.16.0 操作系统:win32 x64

ERROR in ./src/assets/styles/style.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/assets/styles/style.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:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.sassLoader (..\node_modules\sass-loader\lib\loader.js:46:72)
ERROR in ./src/app/modules/shared/components/loader/loader.component.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:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.sassLoader (..\node_modules\sass-loader\lib\loader.js:46:72)
i 「wdm」: Failed to compile.

i have tried deleting node_modules and reinstalling it also我试过删除 node_modules 并重新安装它


Delete `package-lock.json` file.
Go to node_module folder and `run rm -rf node_modules`.
Run `npm install`

npm rebuild --force
npm rebuild node-sass --force

试试这个,这一次解决了我的问题

npm install node-sass -g 

Try to run npm audit fix to update your dependencies.尝试运行npm audit fix来更新您的依赖项。 I had faced a similar issue and was able to fix by running it.我遇到了类似的问题,并且能够通过运行它来解决。

尝试使用 npm uninstall 卸载,然后再次尝试安装。

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

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