Error “custom keyword definition is invalid: data.

2019-04-18 05:54发布

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?

4条回答
你好瞎i
2楼-- · 2019-04-18 06:25

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

npm uninstall ajv
npm install ajv@6.8.1
查看更多
何必那么认真
3楼-- · 2019-04-18 06:27

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楼-- · 2019-04-18 06:31

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"
}
查看更多
我命由我不由天
5楼-- · 2019-04-18 06:33

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.

查看更多
登录 后发表回答