Module Error (from ./node_modules/sass-loader/dist/cjs.js): Cannot find module 'sass'

I wrote to terminal:

npx create-react-app my-app --template redux-typescript

then i wrote

npm install -g sass

and i see in therminal

changed 17 packages in 2s
2 packages are looking for funding
  run `npm fund` for details
PS D:\WEB\portfolio\pizza> 

but in my package,json i don’t see it

  "dependencies": {
"@reduxjs/toolkit": "^1.9.2",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
"@types/jest": "^27.5.2",
"@types/node": "^17.0.45",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",
"react-router-dom": "^6.8.1",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"


and when i wrote
import "./sass/main.scss"
i see

Module Error (from ./node_modules/sass-loader/dist/cjs.js):
Cannot find module 'sass'

>Solution :

By using the -g flat, you are installing the package to the global scope. To add a package to package.json, just run npm install sass at the react app root directory.

Leave a Reply