我将module-resolver
插件添加到 .babelrc 中,以便能够在nextjs项目中使用别名。
"plugins": [
[
"module-resolver",
{
"root": [
"./"
],
"alias": {
"components": "./app/components",
"pages": "./app/pages",
"themes": "./app/themes"
}
}
]
]
一切正常,但是自从我添加了此配置以来,我的eslint配置会生成导入/无法解决的错误。
[eslint]无法解析模块'components / HOC'的路径。 [导入/未解决]
要解决此问题,我尝试像这样更新 .eslintrc.json 设置:
"settings": {
"import/resolver": {
"components": "./app/components",
"pages": "./app/pages",
"themes": "./app/themes"
}
},
但是,此新配置无效。我想正确解决此问题,您是否有适当解决此问题的想法?
谢谢!
答案 0 :(得分:1)
在您的jsconfig.json
上添加此设置(对于TypeScript,tsconfig.json
)
参考:
[SO]: Adding leading underscores to assembly symbols with GCC on Win32? (@ephemient's answer)
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"components": ["./app/components"],
"pages": ["./app/pages"],
"themes": ["./app/themes"]
}
}
}