ajv: NPM: 6.9.0 AJV Commit causing failure to execute node_modules (multiple dependencies affected i.e. ESLint and WebPack Loaders)

What version of Ajv are you using? Does the issue happen if you use the latest version?

Latest version (6.9.0 release I believe)

Ajv options object

node_modules/ajv/lib/keyword.js:65
      throw new Error('custom keyword definition is invalid: '  + this.errorsText(validateDefinition.errors));
      ^

Error: custom keyword definition is invalid: data.errors should be boolean
    at Ajv.addKeyword (/home/mmacheerpuppy/git/fsa/react-application/node_modules/ajv/lib/keyword.js:65:13)
    at module.exports (/home/mmacheerpuppy/git/fsa/react-application/node_modules/ajv-errors/index.js:10:7)
    at Object.<anonymous> (/home/mmacheerpuppy/git/fsa/react-application/node_modules/schema-utils/src/validateOptions.js:22:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)

What results did you expect?

Expected to be able to build node_modules but experiencing above stacktrace.

Are you going to resolve the issue? Current workaround is to remove ESLint dependencies for NPM users, or if using YARN to resolve dependencies to forced version. It’s also possible (with the addition of another dependency) to use NPM resolutions (see conversation).

Reproduction

Try using the following packages declaration. npm post install will fail to start. ESLint relies on AJV.

{
  "name": "food-standards",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    
    "axios": "^0.18.0",
    "bootstrap": "^4.2.1",
    "react": "^16.8.1",
    "react-dom": "^16.8.1",
    "react-scripts": "2.1.3",
    "reactstrap": "^7.1.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "axios-mock-adapter": "^1.16.0",
    "eslint": "5.6.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.1",
    "eslint-plugin-react": "^7.11.0",
    "react-testing-library": "^5.5.3"
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 45
  • Comments: 45 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Add

  "resolutions": {
    "ajv": "6.8.1"
  }

to your package.json will create a work around (I am using yarn, don’t know if it will work for npm)

This is certainly related to the latest changes made in the commit history.

released 6.9.1

@velocity-360 I’m trying to write a technical test for a job interview in React! 🤣

  "dependencies": {
    "react": "^16.8.1",
    "react-dom": "^16.8.1",
    "react-scripts": "2.1.3",
    "ajv": "6.8.1"
  }

this worked for me using npm

workaround for yarn users: add

  "resolutions": {
    "ajv": "6.5.5"
  }

to your package.json and re run yarn install

I fixed this issue by resorting to an old version that I knew worked. Ran this npm install --save ajv@6.6.2

@gregoriB Yeah, I ran npm i after adding "ajv": "6.8.1" to my package.json and it didn’t work.

I tried again with "ajv": "6.8.1" in my package.json and ran rm -rf node_modules, npm cache clean --force, and then npm i and that did the trick. I’ve now got create-react app up and running.

just add

  "resolutions": {
    "ajv": "6.8.1"
  }

to your package.json

if you use yarn: run yarn install

if you use npm: https://github.com/rogeriochaves/npm-force-resolutions TL;DR

rm -rf node_modules
npx npm-force-resolutions
npm install

Can confirm for React users it’s ESLint and ESLint addons which are causing the issue in the dependency chain. Removing these and running npm install && npm start was sufficient to get me back on development.

{    
    "eslint": "5.6.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.1",
    "eslint-plugin-react": "^7.11.0",
}

So if you’re in a hurry to get back on it, its time to get bare with React!

It probably is possible to make travis CI run tests of some dependencies against the new tags (e.g. webpack and eslint).

it is 3:30am london time, so a few more hours before @epoberezkin wakes up and releases a new version, time to go do something else for a bit!

Can confirm, this is happening for me too when scaffolding Vue JS projects. Currently on Vue CLI 3.4.0, Mac OS 10.13.4. Please fix soon as this is causing serious delays.