babel-plugin-module-resolver不适用于节点

时间:2019-10-03 11:02:19

标签: javascript node.js reactjs

在我的节点应用程序中,我使用了babel-plugin-module-resolver清理导入。但这不能确定我设置的进口。这是我的babelrc。

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

这是我的eslintrc。

module.exports = {
  env: {
    es6: true,
    node: true,
  },
  extends: [
    'airbnb-base',
  ],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly',
  },
  parserOptions: {
    ecmaVersion: 2018,
    sourceType: 'module',
  },
  rules: {
    // "object-curly-newline": ["error", {
    //   "ImportDeclaration": { "minProperties": 4 },
    //   "ExportDeclaration": { "minProperties": 4 }
    // }],
  }
};

这是我的依赖项。

"dependencies": {
    "@hapi/joi": "16.1.4",
    "babel-plugin-module-resolver": "3.2.0",
    "bcrypt": "3.0.6",
    "config": "3.2.2",
    "eslint-import-resolver-babel-module": "5.1.0",
    "express": "4.17.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",
    "concurrently": "4.1.2",
    "eslint": "6.4.0",
    "eslint-config-airbnb-base": "14.0.0",
    "eslint-plugin-import": "2.18.2",
    "nodemon": "1.19.2"
  }

我在这里做错了什么?该错误显示 无法解析路径

0 个答案:

没有答案