【问题标题】:Not able to build node js project for a specifc imported library无法为特定的导入库构建节点 js 项目
【发布时间】:2020-08-27 16:59:38
【问题描述】:

我在我的 vue.js 项目中导入库。仅对于 Library1,没有错误。当我为我正在导入的库 2 运行我的 vue 节点 js 项目构建时,它总是在下一行失败并卡住消息“为生产而构建”。

Could not find implementations for the following rules specified in the configuration:
no-explicit-any
Try upgrading TSLint and/or ensuring that you have all necessary custom rules  installed.
If TSLint was recently upgraded, you may have old rules configured which need to be cleaned up.

有没有办法让 npm build 忽略这个?

下面是我的 .eslintrc.js

module.exports = {
      root: true,
      env: {
        node: true
      },
      'extends': [
        'plugin:vue/essential',
        'eslint:recommended',
        '@vue/typescript/recommended'
      ],
      parserOptions: {
        ecmaVersion: 2020,
        ecmaFeatures: {
          legacyDecorators: true,
        },
      },
      rules: {
        '@typescript-eslint/no-var-requires': 0,
        '@typescript-eslint/ban-ts-ignore': 'off',
        "@typescript-eslint/no-explicit-any": "off",
   }
  }

我是否需要更新我的 tsconfig 或 tslint 以在构建生产时停止检查。这仅发生在我正在使用的 vue 库项目中。

我使用 npm link 和 npm link 来链接和安装库。

【问题讨论】:

    标签: javascript node.js typescript vue.js vuejs2


    【解决方案1】:

    修复它的最简单方法是删除 tslint。因为你已经有了 eslint。你只需要安装一些额外的 eslint 包

    npm i -D @typescript-eslint/eslint-plugin;
    npm i -D @typescript-eslint/parser;
    npm i -D eslint;
    

    以下是推荐

    
    module.exports = {
        env: {
            commonjs: true,
            es6: true,
            node: true,
        },
        extends: [
            "eslint:recommended",
            "plugin:@typescript-eslint/eslint-recommended",
            "plugin:@typescript-eslint/recommended",
            "plugin:@typescript-eslint/recommended-requiring-type-checking",
        ],
        globals: {
            Atomics: "readonly",
            SharedArrayBuffer: "readonly",
        },
        parser: "@typescript-eslint/parser",
        parserOptions: {
            project: "./tsconfig.json",
            ecmaVersion: 2019,
        },
        plugins: ["@typescript-eslint"],
        rules: {
    .....
        }
    }
    
    

    注意:

    在您的tsconfig.json 添加包含部分。顾名思义,这包括源文件的路径。而 exclude 则相反

    
    {
      "compilerOptions": {
    ....
      },
      "exclude": [
        "/node_modules/",
        "./config/"
      ],
      "include": [
        "./src/*.ts",
        "./src/**/*.ts",
        "./src/**/**/*.ts",
        "./src/**/**/**/*.ts"
      ]
    }
    

    【讨论】:

      猜你喜欢
      • 2017-04-27
      • 2020-12-23
      • 1970-01-01
      • 1970-01-01
      • 2016-01-25
      • 1970-01-01
      • 2018-08-17
      • 2021-01-07
      • 1970-01-01
      相关资源
      最近更新 更多