16

After I create a sample react app using create-react-app, npm start fails.

I have tried this using node 11.4 and 10.4 (npm 6.4.1)

npm install create-react-app -g
create-react-app t2
cd t2
npm start

Expected

To be able to start simple react server to hit in browser at localhost:3000

Actual

Server did not start, got this in my terminal:

$ npm start

> [email protected] start /Users/samr/dev/githubs/react/t2
> react-scripts start

/Users/samr/dev/githubs/react/t2/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/samr/dev/githubs/react/t2/node_modules/ajv/lib/keyword.js:65:13)
    at module.exports (/Users/samr/dev/githubs/react/t2/node_modules/ajv-errors/index.js:10:7)
    at Object.<anonymous> (/Users/samr/dev/githubs/react/t2/node_modules/schema-utils/src/validateOptions.js:22:1)
    at Module._compile (internal/modules/cjs/loader.js:723:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:734:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Module.require (internal/modules/cjs/loader.js:659:17)
    at require (internal/modules/cjs/helpers.js:22:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start 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!     /Users/samr/.npm/_logs/2019-02-09T23_19_40_848Z-debug.log
3
  • Looks like a known issue: github.com/webpack/webpack/issues/8768 Commented Feb 9, 2019 at 23:47
  • I'm running into this as well. Npm start worked fine for me for an app I created last night, but today I tried to use create-react-app for a new project, and in the new project npm start is not working for me. Copying over my node_modules folder from my previous app did help as a temporary workaround, but once I tried installing react router into my new app and then running npm start, I'm running into this error once again. Commented Feb 10, 2019 at 0:07
  • same here, maybe you can check this github.com/webpack/webpack/issues/8768, changing the file in file node_modules\ajv-errors\index.js as someone says here solved it for now as a quick fix Commented Feb 10, 2019 at 0:16

5 Answers 5

11

As @atsnam has said, you can find the resolution here https://github.com/webpack/webpack/issues/8768.

If you use yarn

add below to package.json

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

then run yarn install

if you use npm

npm uninstall ajv
npm install [email protected]

That worked for me

Sign up to request clarification or add additional context in comments.

4 Comments

it won't work if you deploy the app. i suggest adding "ajv": "6.8.1" into the dependencies instead
Just modify to npm install --save [email protected]
if you're using npm 5 or newer, all installs should be saved to package.json by default
I had the same issue with a TomTom ReactJS sample I got off GitHub. This answer resolved the problem.
9

Quick fix is mentioned here :

Essentially go to node_modules/ajv/lib/keyword.js and comment out lines 64 and 65.

1 Comment

There is no ajv folder in my node_modules directory
1

just add resolutions to your package.json like this:

  { 
    "dependencies": {
      ...
    }
    "resolutions": {
      "ajv": "6.8.1"
    }
  }

then run npm install. if you use yarn, yarn install

1 Comment

I added this, did the npm install, but npm start still fails the same way.
0

As per the suggestion in Github answers the below change has enabled me to work.

To fix this error, just change:
Line 14: `errors: 'full',`
to:
Line 14: `errors: true`
in file **node_modules\ajv-errors\index.js**

Comments

0

The accepted answer didn't work for me. Instead i did this:

  • deleted node_modules folder.
  • cd to project parent directory.

    npm install
    npm start

This worked like a charm.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.