webpack - 未找到模块:错误:无法解析 './foo/foo.scss' in
问题描述
我无法将我的 scss 文件导入到我的 tsx 文件中。我收到以下错误:
./wwwroot/clientapp/components/technology/technology.tsx 中的错误模块未找到:错误:无法解析 'C:\Repo\hobby\01.Code\Core\wwwroot 中的 './technology/technology.scss' \clientapp\components\technology' @ ./wwwroot/clientapp/components/technology/technology.tsx 3:0-38 @ ./wwwroot/clientapp/app.tsx npm 错误!代码 ELIFECYCLE npm 错误!errno 2 npm 错误!asp.net@1.0.0 构建:
webpack
npm 错误!退出状态 2 npm ERR!npm 错误!在 asp.net@1.0.0 构建脚本中失败。npm 错误!这可能不是 npm 的问题。上面可能有额外的日志输出。
我的网络包:
{
test: /\.scss$/,
use: [
{ loader: "style-loader" },
{
loader: "typings-for-css-modules-loader",
options: {
namedexport: true,
camelcase: true,
modules: true
}
},
{ loader: "sass-loader" }
]
},
在新文件夹类型下添加了声明文件:
declare module '*.css' {
const content: { [className: string]: string; };
export default content;
}
declare module '*.scss' {
const content: { [className: string]: string; };
export default content;
}
然后导入:
import './foo/foo.scss';
当我这样做时,npm run build
我收到上述错误。
解决方案
如果您从错误消息中更改导入
'./technology/technology.scss'
到
'./technology.scss'
它应该可以工作,你能检查一下吗?
推荐阅读
- php - mysql从与其他表相关的表返回结果
- python - AttributeError:'Recognizer' 对象没有属性'recognize_azure'
- c# - POST 方法不生成新行
- ascii - 是否可以在 Flowgarithm 中添加换行符?
- jmeter - jmeter中的Loadrunner web_custom_request模拟
- javascript - 从 Iterable 的 Promise 创建的 RxJs Observable 不会在每次迭代时更新值
- python - 如何根据多个条件更改列的一部分中的值?
- excel - 当我没有选择多个范围时,为什么会收到运行时间错误 1004?
- tensorflow - Keras 自定义损失函数打印张量值
- python - 根据下一列熊猫中的重复范围迭代列值