在我的节点应用程序中,我已经配置了eslint。后来我想使用模块解析器。这是我的package.json文件。
"dependencies": {
"@hapi/joi": "16.1.4",
"bcrypt": "3.0.6",
"config": "3.2.2",
"express": "4.17.1",
"jsonwebtoken": "8.5.1",
"mongoose": "5.7.1",
"request": "2.88.0",
"winston": "3.2.1",
"yarn": "1.17.3"
},
"devDependencies": {
"@babel/cli": "7.6.2",
"@babel/core": "7.6.2",
"@babel/node": "7.6.2",
"@babel/preset-env": "7.6.2",
"babel-eslint": "10.0.3",
"babel-plugin-module-resolver": "^3.2.0",
"concurrently": "4.1.2",
"eslint": "6.5.1",
"eslint-config-airbnb": "18.0.1",
"eslint-import-resolver-babel-module": "^5.1.0",
"eslint-plugin-import": "2.18.2",
"nodemon": "1.19.2"
}
这是我的eslintrc文件。
module.exports = {
env: {
es6: true,
node: true,
},
extends: [
'airbnb-base',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
rules: {
"indent": ["warn", 2],
"quotes": ["warn", "single"],
"no-unused-vars": ["error", {"warn": "none"}],
"max-len": ["warn", 150],
"no-console": 1,
"object-curly-newline": ["warn", {
"ObjectPattern": { "multiline": true },
"ExportDeclaration": { "multiline": true, "minProperties": 4 }
}],
},
};
这是我的babelrc文件。
{
"presets": ["@babel/preset-env"],
"plugins": [
["babel-plugin-module-resolver", {
"alias": {
"root": "./",
"middleware": "./middleware"
}
}]
]
}
但是,当我尝试导入某些内容时,这总是给我这个错误。 无法解析模块“中间件”的路径。
我在这里做错了什么?