9
7

More than 5 years have passed since last update.

npm startがwebpackの不具合で起動しなくなったので修正方法のメモ

Last updated at Posted at 2019-02-10

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 || {}
    },

参考

9
7
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
7