Build: Cannot find module OurFirstAppWithFVisualStudio.module.scss

I use visual studio NodeJS tools to create an SPF application, as shown here:

https://github.com/SharePoint/sp-dev-docs/wiki/Working-with-visual-studio

However, after completing all the steps, I have this error

Severity Code Description Project File Line Suppression State Build Error: Module "./OurFirstAppWithFVisualStudio.module.scss. NodejsApp1 E: \ GoogleDrive \ Labs \ SPF \ OurFirstSPFAppWithVisualStudio \ src \ webparts \ ourFirstAppWithFVisualStudio \ Our

When I checked the solution, I noticed that the .scss file was excluded from the solution, so my first step was to include it in the project.

However, this had no effect.

enter image description here

+5
source share
1 answer

Perhaps the problem is that typescript cannot find the typing for your module OurFirstAppWithFVisualStudio.module.css , which your module cannot solve. Try require styles. If typescript cannot solve the require function, add the following to the .d.ts file

 declare interface IRequire { <T>(path: string): T; (paths: string[], callback: (...modules: any[]) => void): void; ensure: (paths: string[], callback: (require: <T>(path: string) => T) => void) => void; } declare var require: IRequire; 

In your project. You do not need to do import styles from './...scss' . Just importing or requiring a file should do the trick. Make sure you configure the style loaders in your webpack.config.js or any other bundle if you are not using webpack. You can follow this to configure bootloaders in webpack. If none of them work, maybe you can create declaration files for your css modules using typed-css-modules

+3
source

All Articles