Mukesh Prajapati
Mukesh Prajapati

Reputation: 864

Cannot find module 'node-sass' while buil Angular app

my global ng version is 1.6.1 and local ng-cli version is 1.6.1 so first warning then i got error,

ERROR in ./src/app/app.component.scss
Module build failed: Error: Cannot find module 'node-sass'

so anyone can help me ?

Upvotes: 0

Views: 8355

Answers (3)

avi.elkharrat
avi.elkharrat

Reputation: 6780

It seems that the node-sass has not been fetched on your desktop when you initiated your angular environment. This probably happened when you launched npm install -g @angular/cli.

If you are working in an enterprise context, using

  • a web proxy
  • a local repository manager (say Nexus) in which packages are first proxified then downloaded to your desktop

then you may encounter this issue.

Explanation:

node-sass uses compiled C libs that are stored in Github. Your local repository manager (a.k.a. Nexus) should not be able to handle such a dependency.

Sollution:

If you are allowed to get out of your enterprise through the proxy, then you should configure the proxy in your .npmrc file (it should not be difficult to find a tuto that explains how). Then relaunch npm install -g @angular/cli.

If you are not allowed to get out of your enterprise through the web proxy, then your only sollution is to ask your Software Factory manager to package this npm module for you, including the C lib dependency.

Note that the situation that i just describe is not uncommon with npm packages.

Upvotes: 3

Anuradha Gunasekara
Anuradha Gunasekara

Reputation: 6983

Try removing the node_modules directory and re-installing the node modules.

Upvotes: 2

Aer0
Aer0

Reputation: 3907

Looks like you're missing node-sass in your project. Try installing it through npm i node-sass -D and rerun again.

Upvotes: 0

Related Questions