LoginSignup
9
6

More than 3 years have passed since last update.

Gatsby.jsでエラーが出た時の魔法のコマンド

Last updated at Posted at 2020-01-22

こんにちは@yukifreeworld12です。
Gatsby.jsで久しぶりに修正しようとGatsbyコマンドを使うと今まで何もなかったのに急にエラーが...そんな時に使えるコマンドをメモ。後世の同じエラーにハマった人の為にも...

問題

ちなみに今回はgatsby buildをするとこんなエラー文が...

 ERROR #95313 

Building static HTML failed for path "/news/outing"

See our docs page for more info on this error: https://gatsby.dev/debug-html


  19 |     renderNode: {
  20 |       "embedded-asset-block": (node) => {
> 21 |         const alt = node.data.target.fields.title['en-US']
     |                                             ^
  22 |         const url = node.data.target.fields.file['en-US'].url
  23 |         return <img alt={alt} src={url} />
  24 |       }


  WebpackError: TypeError: Cannot read property 'title' of undefined

  <略>


WebpackError: TypeError: Cannot read property 'title' of undefinedと
書いてありますが'title'の部分は毎回違うのでとりあえず似たようなエラーなら以下のコマンドで解決。

魔法のコマンド

rm -rf ./.cache && rm -rf ./.node_modules && yarn install && yarn dev

大体このコマンドを使えば解決するはずです。

最後に

今日も見てくれてホンマありがとな!!
記事がええなと思ったらフォローといいねホンマよろしくな!!
(ジョーブログ風に)

9
6
1

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
6