๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿชฒ debug

[turboRepo scss] Cannot find module './mybutton.module.scss' or its corresponding type declarations.ts(2307)

๐Ÿ•ต๏ธ ์ด์Šˆ

scss๋กœ ๋ฒ„ํŠผ ๋งŒ๋“ค์–ด๋ณด๊ธฐ ์ค‘..๋‹ค์Œ๊ณผ ๊ฐ™์€ ts ๊ฒฝ๊ณ ๊ฐ€ ๋–ด๋‹ค.

 

๋ฌธ์ œ๋Š” ts์™€ tsx ํ™•์žฅ์ž๋กœ ๋๋‚ด์•ผ๋งŒ ๋ชจ๋“ˆ๋กœ ์ธ์‹ํ•ด์„œ scss ํ™•์žฅ์ž์˜ ํŒŒ์ผ์„ ์ธ์‹ํ•˜์ง€ ๋ชปํ•œ ๊ฑฐ์˜€๋‹ค.

 

๐Ÿ“ ํ•ด๊ฒฐ

1. tsconfig.ts ์™€ ๊ฐ™์€ ์ตœ์ƒ๋‹จ ๊ฒฝ๋กœ์— typings ํด๋”๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์ž.

2. typings/ ํด๋” ๋‚ด์— declarations.d.ts ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์ฃผ๊ณ  ๋‹ค์Œ์˜ ์ฝ”๋“œ ์ž‘์„ฑ.

declare module "*.scss" {
  const content: Record<string, string>;
  export default content;
}

 

3. tsconfig.ts ์— typings ํด๋” ์ถ”๊ฐ€ํ•ด์ฃผ๊ธฐ

{
  "extends": "@repo/typescript-config/react-library.json",
  "compilerOptions": {
    "outDir": "dist"
  },
  "include": ["typings", "src"], // typings ์ถ”๊ฐ€
  "exclude": ["node_modules", "dist"]
}

 

๐Ÿ“š References

 

https://stackoverflow.com/questions/72701371/cannot-find-module-src-styles-scss

 

Cannot find module "@src/styles.scss"

I import the style file in my project like this: import styles from '@src/styles.scss'; The tsconfig.json file contains: { "compilerOptions": { "module": "CommonJS&quo...

stackoverflow.com