babel-plugin-module-resolver doesn't work with eslint in node

Viewed 612

In my node application, I had configured eslint. Later I wanted to use module-resolver. This is my package.json file.

"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"
  }

This is my eslintrc file.

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 }
    }],
  },
};

This is my babelrc file.

{   
  "presets": ["@babel/preset-env"],
  "plugins": [
    ["babel-plugin-module-resolver", {
      "alias": {
        "root": "./",
        "middleware": "./middleware"
      }
    }]
  ]
}

But when I tried to import something, this keeps giving me this error. Unable to resolve path to module 'middleware'.

What am I doing wrong here?

0 Answers
Related