create-react-app
を使ってReactプロジェクトを作成し、npm start
を実行すると、
/Users/wildmouse/helloworld/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
というエラーが発生し、起動しなかったため修正方法を記録しておきます。
私の場合はcreate-react-app
に関連して本エラーに遭遇しましたが、webpackを使っている場合なら発生するエラーと思われます。
なおこの不具合は10 Feb 2019, 08:37 GMT+9
にgithubのwebpackリポジトリに報告されており、修正方法が共有されているため、間も無く修正が完了すると思われます。
現時点ではnpmリポジトリ側の修正はできていないようですが、しばらく経過するとパッケージをupdateすることで修正できる可能性があります。
修正方法
webpackの依存パッケージであるnode_modules/ajv-error
内にある、index.jsに以下の修正を加えることでエラーが発生しなくなります。
修正前のnode_modules/ajv-errors/index.js(14行目付近)
ajv.addKeyword('errorMessage', {
inline: require('./lib/dotjs/errorMessage'),
statements: true,
valid: true,
errors: 'full', // ここが原因
config: {
KEYWORD_PROPERTY_PARAMS: {
required: 'missingProperty',
dependencies: 'property'
},
options: options || {}
},
修正後のnode_modules/ajv-errors/index.js(14行目付近)
ajv.addKeyword('errorMessage', {
inline: require('./lib/dotjs/errorMessage'),
statements: true,
valid: true,
errors: true, // 'full',を true, に変更する
config: {
KEYWORD_PROPERTY_PARAMS: {
required: 'missingProperty',
dependencies: 'property'
},
options: options || {}
},