Cannot find module '../scss/Navbar.scss' or its corresponding type declarations. When I want to use sass file in typescript project

Viewed 31

Im completely new to react typescript projects.

Im scaffolding a typescript project using this:

npx create-react-app test --template typescript 

And then I setup a sass module succefylly and configure it to package.json file by:

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "sass": "sass src/scss:src/css --watch --no-source-map"
  }

Everything is okay And all stuff are build but when I want to use a sass file :

import styles from "../scss/Navbar.scss"

this error occured:

 Cannot find module '../scss/Navbar.scss' or its corresponding type declarations.

The file is in there and sass file location address is completely correct but I cant solve this error, please help me tnx.

1 Answers

The main problem is exactly the file name. (That is a css module feature)

So instead of :

Navbar.scss

I should change to:

Navbar.module.scss
Related