Error “custom keyword definition is invalid: data.errors should be boolean”

南笙酒味 提交于 2019-12-22 01:28:33

问题


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?


回答1:


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

npm uninstall ajv
npm install ajv@6.8.1



回答2:


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"
}



回答3:


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




回答4:


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.



来源:https://stackoverflow.com/questions/54611735/error-custom-keyword-definition-is-invalid-data-errors-should-be-boolean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!