TusharG
TusharG

Reputation: 505

running angular project gives error for node-sass

I am running an angular project in my local environment with versions specified below.

npm version : 6.9.0
Angular CLI: 7.3.9
Node: 10.16.0
OS: win32 x64

and i cannot run project and get the errors below:

    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


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

Upvotes: 9

Views: 16038

Answers (4)

Deepika
Deepika

Reputation: 1

Try to uninstall using npm uninstall and again try to install.

Upvotes: 0

Muhammed Albarmavi
Muhammed Albarmavi

Reputation: 24406

Try this, this solved my problem once

npm install node-sass -g 

Upvotes: 4

Chanaka Weerasinghe
Chanaka Weerasinghe

Reputation: 5742

Install

npm install --save-dev --unsafe-perm node-sas

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

Credit https://github.com/xzyfer

Upvotes: 0

Govind Sah
Govind Sah

Reputation: 116

Try to run npm audit fix to update your dependencies. I had faced a similar issue and was able to fix by running it.

Upvotes: 1

Related Questions