zoukankan      html  css  js  c++  java
  • ESLint 报错 import/no-unresolved

    解决方法是:在 .eslintrc 中设置

    "rules": {
        "import/extensions": [2, "never", { "web.js": "never", "json": "never" }],
       "import/no-extraneous-dependencies": [2, { "devDependencies": true }],
       "import/no-unresolved": [2, { "ignore": ["antd-mobile"] }]
    }
    以上的方法不行的话,试试下面的方法:

    归根结底的原因是因为eslint不识别webpack的路径别名

    安装 eslint-import-resolver-webpack
    在.eslinttrc.js中配置
    module.exports = {
    root: true,
    'settings': {
    "import/resolver": {
    "webpack": {
    //此处config对应webpack.config.js的路径,我这个路径是vue-cli3默认的路径
    "config": "node_modules/@vue/cli-service/webpack.config.js"
    }
    }
    }
    }
    此时引入问题已解决,但是需要引入文件加上后缀名,如果想忽略后缀名,可以继续在eslint配置文件中这样:
    /* .eslinttrc.js */

    module.exports = {
    root: true,
    'settings': {
    "import/resolver": {
    "webpack": {
    "config": "node_modules/@vue/cli-service/webpack.config.js"
    }
    }
    },
    rules: {
    'import/extensions': ['error', 'always', {
    'js': 'never',
    'vue': 'never'
    }]
    }
    }

  • 相关阅读:
    Java 单测 回滚
    Java四种线程池的使用
    git gc
    Git 常用命令
    JPA 批量新增
    SpringData JPA 排除 扫描 exclude-filter 不能使用解决
    开源许可证GPL、BSD、MIT、Mozilla、Apache和LGPL的区别
    深入浅出 RPC
    阿里 Java面试 知识点
    Eclipse Egit 安装
  • 原文地址:https://www.cnblogs.com/guwufeiyang/p/12887335.html
Copyright © 2011-2022 走看看