Search code examples
dockerjestjscreate-react-app

eslint-config-react-app/jest': Cannot read property 'meta' of undefined


I create a project with create-react-app. I get this error when i run docker build frontend -t my-frontend . :

> [email protected] 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! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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

how should i fix it? i tried npm install,npm install .,npm audit fix.

this is jest in my 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"
    ]
  },
  ...
}

and this is jest in my 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"
      }
    },

I also saw eslint-plugin-jest gives "ESLint stack trace: TypeError: Cannot read property 'meta' of undefined" that says: " This was a temporary issue in 22.6 up to 22.6.2" but my version is 24.1.3 .


Solution

  • Fixed by npm audit fix --force but before run, make sure it does not damage your project.

    npm audit fix only modifies the dependencies that shouldn't cause problems based on SEMVER rules. The --force is a dangerious option because it upgrades the dependencies regardless of any rules. This can cause a dependency to go from version 1.2. 0 to version 2.3.

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