На самом деле у меня есть файл typings.d.ts в src (NestJS).
Код: Выделить всё
declare module '*.module.css' {
const classes: { [key: string]: string };
export default classes;
}
declare module '*.png';
declare module '*.svg';
declare global {
declare const NEXT_PUBLIC_SOME_URL: string;
}
Код: Выделить всё
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2021",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": false,
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false,
"jsx": "react-jsx",
"plugins": [{ "name": "typescript-plugin-css-modules" }]
},
"include": ["src", "src/typings.d.ts"]
}
Код: Выделить всё
import React from 'react';
import styles from './App.module.css';
function App() {
return (
Edit src/App.tsxLearn React
);
}
export default App;
и ошибка:
Код: Выделить всё
Error: Cannot find module './App.module.css'
Require stack:
- C:\Users\sebas\Desktop\WeatherStation 3.0\my-app\backend\dist\front\src\App.js
- C:\Users\sebas\Desktop\WeatherStation 3.0\my-app\backend\dist\backend\src\app.service.js
- C:\Users\sebas\Desktop\WeatherStation 3.0\my-app\backend\dist\backend\src\app.controller.js
- C:\Users\sebas\Desktop\WeatherStation 3.0\my-app\backend\dist\backend\src\app.module.js
- C:\Users\sebas\Desktop\WeatherStation 3.0\my-app\backend\dist\backend\src\main.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Function.Module._load (node:internal/modules/cjs/loader:985:27)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object. (C:\Users\sebas\Desktop\WeatherStation 3.0\my-app\front\src\App.tsx:2:1)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Function.Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19)
Когда я удаляю стили импорта из «./App.module.css»; сервер запускается на указанном порту и отображает страницу без стили. Файл CSS имеет имя App.module.css
Подробнее здесь: https://stackoverflow.com/questions/781 ... module-css
Мобильная версия