5

I have an issue very similar to this question, where a "cannot find module" error is thrown when trying to import CSS modules. However, the suggested answer to that question is to create a declaration.d.ts file like the following:

declare module "*.sass" // or .css or .scss, I am using sass 

This works—kind of. For some reason, VSCode shows me the error only when the .d.ts file is not open. If I keep the declaration file open all the time, no error is shown. However, I obviously don't want to keep the file open all the time, and I would like to just get it to work.

Does anyone know a fix to this problem in VSCode? Perhaps a setting or an extension?

Additional information:

  • VSCode version: 1.65.2
  • OS: Mac OS Big Sur

1 Answer 1

0

I experienced the same exact issue when closing my declaration.d.ts file - I just moved declaration.d.ts to inside my src folder and it went away

Sign up to request clarification or add additional context in comments.

1 Comment

Hmm, I’ll check this out. I haven’t been using CSS modules recently but I’ll check if the problem still occurs with your fix.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.