18

I just created a new React application using this command:

create-react-app mysite.com

After installation, when I tried to open it using npm start and yarn start, I got the following error.

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/myAccount/Documents/Dev/Projects/ReactJS/mysite.com/node_modules/ajv/lib/keyword.js:65:13)

How can I fix this problem?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ishan Patel
  • 5,571
  • 12
  • 47
  • 68
  • Not sure, but maybe dots are not allowed in project names? That would probably cause such an error... – Luan Nico Feb 09 '19 at 23:12
  • Thank you @Luan, I just created a new app with no dots and no capital letters: `create-react-app profilesite`, but it's still giving me same error. – Ishan Patel Feb 09 '19 at 23:17
  • You could also try to update your global installation of create-react-app to the latest version, or at least check in which version you are. Again, just a guess. – Luan Nico Feb 09 '19 at 23:18

4 Answers4

25

Reverting to a stable version of the ajv library also works:

npm uninstall ajv
npm install ajv@6.8.1
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Roberto Rodriguez
  • 3,179
  • 32
  • 31
10

I thought that was something new coming with "@symfony/webpack-encore": "^0.23.0". However, there's an issue with the ajv library.

Dirty fix:

In

node_modules\ajv-errors\index.js

change the errors: parameter at line 14 from 'full' to true.

Clean fix (temporary):

Modify your package.json using this:

"resolutions": {
    "ajv": "6.8.1"
}
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
rnenciu
  • 368
  • 4
  • 13
9

Comment out node_modules/ajv/lib/keyword.js at line 64-65 for a workaround solution:

if (!validateDefinition(definition))
  throw new Error('custom keyword definition is invalid: '  + this.errorsText(validateDefinition.errors));

Ref: https://github.com/webpack/webpack/issues/8768

mobject
  • 179
  • 5
3

I get this error when I try and make a new nuxt application with npx:

npx create-nuxt-app <project-name>

I did

npm uninstall ajv
npm install ajv@6.8.1 

Like @robert Rodriguez, it works, no errors.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Justin
  • 215
  • 1
  • 9
  • I'm not going to downvote but what does this answer add to Robert Rodriguez's one? – skywalker Feb 10 '19 at 17:55
  • For starters confirmation that it works. 2nd that React isn't the only place where this error is popping up. I'm using Nuxt and not React, maybe someone who looks up this issue for a Nuxt project they will find this helpful. 3rd His solution is simple and does not involve tweaking ajv package files. Please let us know Les if you have a better solution to this issue. I would like to see it. Thanks! – Justin Feb 10 '19 at 21:06
  • Ok thanks for the explanation, I'm sorry for bothering. (I don't have any other solution). – skywalker Feb 11 '19 at 19:03