![](/img/trans.png)
[英]Cannot find module './styles.scss' or its corresponding type declarations
[英]Cannot find module '../scss/Navbar.scss' or its corresponding type declarations. When I want to use sass file in typescript project
我对响应打字稿项目是全新的。
我使用这个脚手架一个打字稿项目:
npx create-react-app test --template typescript
然后我成功设置了一个 sass 模块并将其配置为 package.json 文件:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"sass": "sass src/scss:src/css --watch --no-source-map"
}
一切都很好,所有的东西都已经构建好了,但是当我想使用 sass 文件时:
import styles from "../scss/Navbar.scss"
发生此错误:
Cannot find module '../scss/Navbar.scss' or its corresponding type declarations.
该文件在那里,sass文件位置地址完全正确,但我无法解决这个错误,请帮助我tnx。
主要问题正是文件名。 (这是一个 css 模块功能)
所以而不是:
Navbar.scss
我应该改为:
Navbar.module.scss
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.