next.js 无法找到模块“webmaster”,请检查此模块是否正确,

eufgjt7s  于 2023-04-20  发布在  其他
关注(0)|答案(1)|浏览(165)

到底发生了什么

error - ESLint: Failed to load plugin 'prettier' declared in '../../.eslintrc.js » ./config/base.eslintrc.js': Cannot find module 'eslint-plugin-prettier' Require stack: - /../projects/xxxxx/xxxx/xxxxx/__placeholder__.js

我只是想升级我的NextJS项目的包,以前它与下面提到的版本工作正常:

  • NodeJS:16.20.0
  • Next.js:10.0.6
  • ReactJS:17.0.1
  • ESLint:7.19.0
  • eslint-config-prettier:7.2.0
  • eslint-plugin-prettier:3.3.1

并升级到以下版本:

  • NodeJS:18.15.0
  • Next.js:13.3.0
  • ReactJS:18.2.0
  • ESLint:8.38.0
  • eslint-config-prettier:8.8.0
  • eslint-plugin-prettier:4.2.1

但现在它是在建设项目的时候抛出错误。

error - ESLint: Failed to load plugin 'prettier' declared in '../../.eslintrc.js » ./config/base.eslintrc.js': Cannot find module 'eslint-plugin-prettier' Require stack: - /../projects/xxxxx/xxxx/xxxxx/__placeholder__.js

请让我知道我如何克服这个问题。

**eslint版本:**8.38.0
**prettier版本:**2.8.7
**eslint-plugin-prettier版本:**4.2.1
我正在使用的配置文件:.eslintrc

module.exports = {
  extends: [
    'airbnb',
    'airbnb/hooks',
    'eslint:recommended',
    'plugin:prettier/recommended'
  ],
  parser: 'babel-eslint',
  parserOptions: {
    ecmaVersion: 9,
    ecmaFeatures: {
      experimentalObjectRestSpread: true,
      impliedStrict: true,
      classes: true
    }
  },
  env: {
    browser: true,
    node: true,
    jest: true
  },
  settings: {
    'import/internal-regex': '^~'
  },
  rules: {
    strict: 0,
    'prettier/prettier': 'error',
    'no-console': 'error',
    'no-debugger': 'error',
    'no-alert': 'error',
    'no-await-in-loop': 0,
    'no-return-assign': ['error', 'except-parens'],
    'no-restricted-syntax': [
      2,
      'ForInStatement',
      'LabeledStatement',
      'WithStatement'
    ],
    'no-unused-vars': [
      'error',
      {
        args: 'all',
        ignoreRestSiblings: true,
        argsIgnorePattern: '^_',
        caughtErrors: 'all'
      }
    ],
    'prefer-const': [
      'error',
      {
        destructuring: 'all'
      }
    ],
    'arrow-body-style': [2, 'as-needed'],
    'no-unused-expressions': [
      2,
      {
        allowTaggedTemplates: true
      }
    ],
    'no-param-reassign': [
      2,
      {
        props: false
      }
    ],
    'import/order': [
      'error',
      {
        groups: [
          'builtin',
          'external',
          'internal',
          'unknown',
          'index',
          ['sibling', 'parent'],
          'object'
        ],
        'newlines-between': 'always',
        pathGroups: [
          {
            pattern: '~/**',
            group: 'internal'
          }
        ],
        pathGroupsExcludedImportTypes: ['builtin', 'external']
      }
    ],
    'import/prefer-default-export': 0,
    import: 0,
    'func-names': 0,
    'space-before-function-paren': 0,
    'comma-dangle': 0,
    'max-len': 0,
    'import/extensions': 0,
    'import/no-named-as-default': 0,
    'no-underscore-dangle': 0,
    'consistent-return': 0,
    'react/display-name': 1,
    'react-hooks/rules-of-hooks': 'error',
    'react-hooks/exhaustive-deps': 'warn',
    'react/no-array-index-key': 0,
    'react/react-in-jsx-scope': 0,
    'react/prefer-stateless-function': 0,
    'react/forbid-prop-types': 0,
    'react/no-unescaped-entities': 0,
    'react/static-property-placement': [1, 'static public field'],
    'jsx-a11y/accessible-emoji': 0,
    'jsx-a11y/click-events-have-key-events': 0,
    'jsx-a11y/no-static-element-interactions': 0,
    'jsx-a11y/no-noninteractive-element-interactions': 0,
    'react/jsx-props-no-spreading': [
      2,
      {
        html: 'enforce',
        custom: 'ignore',
        explicitSpread: 'ignore'
      }
    ],
    'react/require-default-props': 0,
    'react/jsx-filename-extension': [
      1,
      {
        extensions: ['.js', '.jsx']
      }
    ],
    radix: 0,
    'no-shadow': [
      2,
      {
        hoist: 'all',
        allow: ['resolve', 'reject', 'done', 'next', 'err', 'error']
      }
    ],
    quotes: [
      2,
      'single',
      {
        avoidEscape: true,
        allowTemplateLiterals: true
      }
    ],
    'jsx-a11y/href-no-hash': 'off',
    'jsx-a11y/anchor-is-valid': [
      'warn',
      {
        aspects: ['invalidHref']
      }
    ]
  },
  plugins: ['react-hooks','prettier']
};
ohtdti5x

ohtdti5x1#

也许你需要在ESLint配置中声明prettier:
您需要在ESLintrc中指定它:

extends: [
    'prettier',
  ],
  plugins: ['prettier'],

然后你可以把你的漂亮的规则(只有当你有一些)直接放在你的eslintrc中,像这样:

rules: {
    'prettier/prettier': [
      'error',
      {
        semi: true,
        /* your rules */
      },
    ],
}

How to use prettier with eslint
希望对你有用!

相关问题