无法加载配置“ @nuxtjs”以从中扩展

问题描述 投票:0回答:1

任何人,请帮助我

将Typescript安装到我的Nuxt项目中并对其进行配置后,我得到此警告:

WARN  Compiled with 1 warnings                                                            
Module Warning (from ./node_modules/eslint-loader/dist/cjs.js):                            friendly-errors 11:28:18
Failed to load config "@nuxtjs" to extend from.
Referenced from: /home/x/nuxt-project/.eslintrc.js                                 friendly-errors 11:28:18
You may use special comments to disable some warnings.                                     friendly-errors 11:28:18
Use // eslint-disable-next-line to ignore the next line.                                   friendly-errors 11:28:18
Use /* eslint-disable */ to ignore all warnings in a file.                                 friendly-errors 11:28:18

这是什么意思以及如何解决?

**这是我的配置步骤:

  • nuxt.config.js中的buildModules: ['@nuxt/typescript-build']
  • 创建tsconfig.json
  • 创建vue-shim.d.ts
  • 为TypeScript安装eslint并删除Nuxt版本
  • 更新皮棉脚本

**这是我的eslintrc.js配置:

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true
  },
  parserOptions: {
    parser: 'babel-eslint',
      ecmaFeatures: {
      legacyDecorators: true
    }
  },
  extends: [
    '@nuxtjs',
    'plugin:nuxt/recommended',
    'eslint:recommended',
    // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
    // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
    'plugin:vue/recommended'
  ],
  plugins: [
    'vue'
  ],
  // add your custom rules here
  rules: {
    'semi': [2, 'never'],
    'no-console': 'off',
    'vue/max-attributes-per-line': 'off',
    "vue/html-self-closing": ["error", {
      "html": {
        "void": "always",
        "normal": "never",
        "component": "any"
      }
    }]
  }
}
typescript vue.js nuxt.js
1个回答
1
投票

对此没有任何经验,但是@nuxtjs eslint的Github表示以下内容:

[如果您使用的是TypeScript,请按照“用法”部分,将@ nuxtjs / eslint-config替换为@ nuxtjs / eslint-config-typescript。在您的.eslintrc中,您需要的是:

{
  "extends": [
    "@nuxtjs/eslint-config-typescript"
  ]
}

因此,基本上,您必须运行npm i @nuxtjs/eslint-config-typescript -D,然后更新eslint extends-config

© www.soinside.com 2019 - 2024. All rights reserved.