【问题标题】:eslint-config-react-app/jest': Cannot read property 'meta' of undefinedeslint-config-react-app/jest':无法读取未定义的属性“元”
【发布时间】:2022-01-30 16:02:28
【问题描述】:

我使用 create-react-app 创建了一个项目。当我运行docker build frontend -t my-frontend . 时出现此错误:

> frontend@0.1.0 build /app
> react-scripts build
Creating an optimized production build...
Failed to compile.
Failed to load plugin 'jest' declared in 'package.json » eslint-config-react-app/jest': Cannot read property 'meta' of undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the frontend@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-01-27T11_11_23_140Z-debug.log
The command '/bin/sh -c npm run build' returned a non-zero code: 1

我应该如何解决它?我试过npm install,npm install .,npm audit fix.

这是我package.json 的笑话:

{
  ...
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    ...,
    "web-vitals": "^1.0.1"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  ...
}

这是我package.lock.json 的笑话:

"eslint-plugin-jest": {
      "version": "24.1.3",
      "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-24.1.3.tgz",
      "integrity": "...",
      "requires": {
        "@typescript-eslint/experimental-utils": "^4.0.1"
      }
    },

我还看到eslint-plugin-jest gives "ESLint stack trace: TypeError: Cannot read property 'meta' of undefined" 说:“这是 22.6 到 22.6.2 中的临时问题”,但我的版本是 24.1.3。

【问题讨论】:

    标签: docker jestjs create-react-app


    【解决方案1】:

    npm audit fix --force 修复,但在运行之前,请确保它不会损坏您的项目。

    npm audit fix 仅根据 SEMVER 规则修改不应导致问题的依赖项。 --force 是一个危险的选项,因为它会升级依赖项而不考虑任何规则。这可能会导致依赖项从版本 1.2 开始。 0 到 2.3 版。

    What did a npm audit fix --force change and how do you fix it?

    【讨论】:

      猜你喜欢
      • 2020-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-13
      • 1970-01-01
      相关资源
      最近更新 更多