skip to Main Content

I’m only starting learning React and faced an issue while importing styles from './TodoOutput.module.scss':

Error from TodoOutput.tsx:

Cannot find module ./TodoOutput.module.scss or its corresponding type declarations.ts(2307)

even though file TodoOutput.module.scss exists, and both scss and sass packages added into both package.json and package-lock.json

Here is TodoOutput/ directory:

enter image description here

Review package.json

Review package-lock.json

Review tsconfig.json

2

Answers


  1. The import looks ok, but when you set paths in tsconfig you need to add baseUrl for example src.

    If this does not help, try renaming the file, maybe you changed the keyboard when naming

    Login or Signup to reply.
  2. I find the problem.
    You need to create a Global.d.ts file inside yours src folder and add following lines.

    declare module "*.module.css";
    declare module "*.module.scss";
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search