Error : Cannot find module '*.module.css'

Darcy Daeseok YU ·2022년 2월 1일
0
import styles from "./NavBar.module.css";

이제껏 잘되던 css module을 가져오는데 아래와 같은 에러가 똭 하니 떳다. 왜!!!??? 내시간...

Cannot find module '*.module.css' or its corresponding type declarations.

그래서 정리한다.

일단 tsconfig.json 파일 안에

{
  "compilerOptions": {
    "target": "es5",
   ...생략
  },
  "include": ["src" or "src/**/*"] // 이문구가 있는지 찾아본다. 둘다 모든 파일을 포함한다고 명시중임
}

모든 파일을 include 할것이기 때문에 다른 설정은 필요없다 .

이제 *.module.css 확장자명을 가지는 파일은 css 모듈이라는 것을 선언한다.

declare module "*.module.css";

파일 위치는 src 폴더밑 / 파일명은 아무거나 원하는 대로 하고 d.ts 확장자명을 기입한다.

예) global.d.ts / declaration.d.ts...

이런 ... 얼탱이없는 오류로 시간 낭비 하지 않기를 .... 여러분 화이팅!

profile
React, React-Native https://darcyu83.netlify.app/

0개의 댓글