Module Error: Cannot find module 'sass' REACT

225 Views Asked by At

I'm building a react app using sass

I wrote to terminal:

npx create-react-app .

then I wrote

    npm install -g sass



    Require stack:
    - D:\intern\neo\node_modules\sass-loader\dist\utils.js
    - D:\intern\neo\node_modules\sass-loader\dist\index.js
    - D:\intern\neo\node_modules\sass-loader\dist\cjs.js
    - D:\intern\neo\node_modules\loader-runner\lib\loadLoader.js
    - D:\intern\neo\node_modules\loader-runner\lib\LoaderRunner.js
    - D:\intern\neo\node_modules\webpack\lib\NormalModule.js
    - D:\intern\neo\node_modules\webpack-manifest-plugin\dist\index.js
    - D:\intern\neo\node_modules\react-scripts\config\webpack.config.js
    - D:\intern\neo\node_modules\react-scripts\scripts\start.js
2

There are 2 best solutions below

0
Tajpuriya On

It seems like you have a problem with the project (D:\intern\neo) configuration.

If you want to install sass globally, go to the terminal and then run the command npm i -g sass with administrator privilege.

If the package is installed properly, go to your neo project remove node_modules dir and package-lock.json file and then run npm i within the directory.

0
Omar Abdo On

You need to install node-sass instead of sass. Run the following commands and it should fix the issue

npm uninstall sass
npm install node-sass

Also, it won't harm to see if your sass-loader needs to be updated

npm install sass-loader@latest