在我的节点项目中,我babel-plugin-module-resolver
曾经有相对路径。
tsconfig.json
{
"compilerOptions": {
"outDir": "build",
"target": "es5",
"module": "commonjs",
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": "./src",
"paths": {
"constants/*": ["constants/*"],
"data/*": ["data/*"],
"database/*": ["database/*"],
"enums/*": ["enums/*"],
"features/*": ["features/*"],
"@library/*": ["library/*"],
}
}
}
.eslintrc
{
"parser": "@typescript-eslint/parser",
"extends": ["plugin:@typescript-eslint/recommended"],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"settings": {
"import/resolver": {
"babel-module": {}
}
},
"rules": {
"semi": ["warn", "always"],
"quotes": ["warn", "single"],
"max-len": ["warn", 150],
"no-console": 1,
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-inferrable-types": [
"warn", {
"ignoreParameters": true
}
]
}
}
.babelrc
{
"presets": [
"@babel/preset-typescript",
"@babel/preset-env"
],
"plugins": [
[
"module-resolver",
{
"alias": {
"config": "./src/config",
"constants": "./src/constants",
"data": "./src/data",
"enums": "./src/enums",
"features": "./src/features",
"library": "./src/library",
"middleware": "./src/middleware",
"utils": "./src/utils"
}
}
]
]
}
当我导入文件时,它不会显示任何错误。可以通过单击导入路径移动到特定文件。但是当它遵守时,它会给出以下错误。
如何解决这个问题?