Create-react-app: Cannot start new project due to Ajv error

Created on 9 Feb 2019  路  12Comments  路  Source: facebook/create-react-app

Is this a bug report?

Yes

Did you try recovering your dependencies?

No

Which terms did you search for in User Guide?

None

Environment

Environment Info:

  System:
    OS: macOS 10.14.2
    CPU: x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  Binaries:
    Node: 10.12.0 - /usr/local/bin/node
    npm: 6.7.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 71.0.3578.98
    Safari: 12.0.2
  npmPackages:
    react: ^16.8.1 => 16.8.1 
    react-dom: ^16.8.1 => 16.8.1 
    react-scripts: 2.1.3 => 2.1.3 
  npmGlobalPackages:
    create-react-app: Not Found

Steps to Reproduce

  1. npx create-react-app my-app --typescript
  2. cd my-app
  3. npm start

Expected Behavior

Starting the development server

Actual Behavior

Build exits with status 1 and the following error appears:

> [email protected] start /Users/pawel/Projects/react-tutorial-app
> react-scripts start

/Users/pawel/Projects/react-tutorial-app/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 (/Users/pawel/Projects/react-tutorial-app/node_modules/ajv/lib/keyword.js:65:13)
    at module.exports (/Users/pawel/Projects/react-tutorial-app/node_modules/ajv-errors/index.js:10:7)
    at Object.<anonymous> (/Users/pawel/Projects/react-tutorial-app/node_modules/schema-utils/src/validateOptions.js:22:1)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1

Reproducible Demo

Not available

Most helpful comment

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

All 12 comments

placing this comment here as well since i see it referenced. this broke a fresh Nuxt project for me. Doing npm i -d [email protected] resolved it for now.

workaround for yarn users:
add

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

to your package.json and re run yarn install

this issue drove me crazy!
@tetreault not working for me ):

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

@viankakrisna what do you know? switched to yarn and it worked like magic! thanks alot 馃槃

Thanks guys!

@viankakrisna adding resolutions worked for me! Thanks

Last fix worked for me, although I would like to see a more general resolution.

As a short term adding "ajv": "6.8.1" to package.json deps should also work.

updated ajv version 6.7.0 -> 6.9.0
downgrade version

yarn add [email protected] or npm install [email protected]

[email protected] is out and should fix this issue. Please let us know if you continue to have issues. Make sure to delete your node_modules and lock files to ensure you grab the latest package.

Was this page helpful?
0 / 5 - 0 ratings