English

​​Vite​React,TypeScript,トラブルシュート

Thumbnail of post image 168

Vite の開発サーバーで「Failed to resolve import “./Foo”… Does the file exist?」と出るのは、import のパスのファイルが見つからないときです。大文字 ...

​​JavaScript​Chromium,Vite,トラブルシュート

Thumbnail of post image 051

fetch で API を呼んで res.json() を実行したときの「Unexpected token ‘<', "<!DOCTYPE "… is not vali ...

​​Lighthouse​HTML,JavaScript,トラブルシュート

Thumbnail of post image 088

Lighthouse の「Browser errors were logged to the console」は、コンソールにエラーが1件でも出ると不合格になります。画像やスクリプトが 404 になる、JavaScript が例外で止 ...

​​React​lazy,startTransition,Suspense,TypeScript,トラブルシュート

Thumbnail of post image 008

React 18 でボタンを押してタブやモーダルの中身を lazy で出したとき、「A component suspended while responding to synchronous input」で画面が真っ白になる場合は、S ...

​​React​oxlint,TypeScript,Vite,トラブルシュート

Thumbnail of post image 020

一覧の props をオブジェクトにまとめて {…props} で渡すと、「A props object containing a “key” prop is being spread into J ...

​​Node.js​OpenSSL,webpack,トラブルシュート

Thumbnail of post image 073

md4 のハッシュや古い webpack 4 のビルドを Node.js 17 以降で動かすと出る ERR_OSSL_EVP_UNSUPPORTED の原因と、sha256 への置き換えや webpack の更新で消えることを確かめた ...

​​JavaScript​Chromium,Node.js,トラブルシュート

Thumbnail of post image 152

fetch で API を呼ぶ URL を組み立てるとき、new URL(‘/api/items’) のように相対パスだけを渡すと「TypeError: Invalid URL」が出ます。基準になる URL(b ...

​​TypeScript​トラブルシュート

Thumbnail of post image 011

関数や型を別ファイルに分けて import したとき、tsc やエディターに出る TS2306: File is not a module を、読み込まれる側のファイルに export を付けて直す方法です。.d.ts の型を imp ...

​​TypeScript​Node.js,トラブルシュート

Thumbnail of post image 151

tsconfig.json の module が commonjs のまま、Node.js の ES モジュールで import.meta.url を使うと、tsc が TS1343 を出します。module を nodenext か ...

​​JavaScript​Chromium,Node.js,トラブルシュート

Thumbnail of post image 134

fetch で API を呼び、res.json() のあとに res.text() で読み直すと「body stream already read」が出ます。本文は1回しか読めないためです。1回だけ読む形や clone() に直すと ...

​​React​TypeScript,Vite,トラブルシュート

Thumbnail of post image 189

API から取ってくる一覧を map で表示すると、画面が真っ白になり Cannot read properties of undefined (reading ‘map’) と出ます。届く前の配列が unde ...

​​Node.js​React,tsx,TypeScript,トラブルシュート

Thumbnail of post image 188

React のコンポーネントを書いた .tsx や、古い Node.js で .ts を node で実行すると ERR_UNKNOWN_FILE_EXTENSION が出ます。Node.js 20〜24 で起こし、tsx や Nod ...

​​JavaScript​Chromium,Node.js,トラブルシュート

Thumbnail of post image 023

別のドメインの API に fetch したときの「blocked by CORS policy」は、API の応答に CORS のヘッダーがないと出ます。直すのは API のサーバーの側です。GET と、JSON を送る POST ...

​​Node.js​JavaScript,V8,トラブルシュート

Thumbnail of post image 140

大きな JSON Lines のファイルを Node.js で読み込んで集計すると出る「JavaScript heap out of memory」を起こし、1行ずつ読む書き方と、ヒープの上限を上げる方法で消えることを確かめました。

​​npm​Node.js,React,トラブルシュート

Thumbnail of post image 030

npm install で出る「npm ERR! code ERESOLVE」は、パッケージが求める相手のバージョン(peerDependencies)と、入っている版が合わないときに出ます。react 18 に react-dom ...

​​Node.js​ES Modules,JavaScript,npm,トラブルシュート

Thumbnail of post image 090

npm のパッケージを上げたら import や require で ERR_PACKAGE_PATH_NOT_EXPORTED が出るのは、exports に書かれていないパスを読んだためです。uuid 8 で起こし、直すと消えるこ ...

​​Node.js​Linux,Vite,トラブルシュート

Thumbnail of post image 034

開発サーバーを起動したときの「EADDRINUSE: address already in use」は、ポートが使用中のときに出ます。ss や lsof で使っているプログラムを見つけて止めるか、別のポートで起動すると消えます。Vit ...

​​Node.js​ES Modules,JavaScript,npm,トラブルシュート

Thumbnail of post image 091

Node.js で import を書くと出る「Cannot use import statement outside a module」を、npm init -y の type: commonjs で起こし、type を modul ...

​​React​TypeScript,useEffect,useState,Vite,トラブルシュート

Thumbnail of post image 150

子コンポーネントから親の state を変えると出る「Cannot update a component」の警告は、子のレンダー中に親の set 関数を呼んでいるのが原因です。親で計算するか、onClick に関数を渡す形に直すと消え ...

​​React​TypeScript,useState,Vite,トラブルシュート

Thumbnail of post image 191

Reactで、ログインした瞬間などに出る「Rendered more hooks than during the previous render.」というエラーのよくある原因は、早めの return のあとに書いた useState ...

​​React​TypeScript,useState,Vite,トラブルシュート

Thumbnail of post image 002

React の「Invalid hook call」は、useState などのフックをイベントハンドラーの中や、コンポーネントの外で呼んだときと、自作のコンポーネントライブラリを入れて React が2つになったときに出ます。実際に ...

​​React​TypeScript,Vite,トラブルシュート

Thumbnail of post image 017

API から取ってきたユーザー情報や Date を JSX にそのまま書くと、画面が真っ白になり、コンソールに Objects are not valid as a React child と出ます。中の文字列を書くか、toLocal ...

​​React​TypeScript,Vite,トラブルシュート

Thumbnail of post image 085

map で一覧を描くとコンソールに「Each child in a list should have a unique “key” prop.」と出るのは、map が返す要素に key がないためです。データの ...

​​Git​コマンドライン,トラブルシュート

Thumbnail of post image 194

git pull が「Need to specify how to reconcile divergent branches.」で止まったら、–no-rebase(マージ)か –rebase(リベース)を付けて ...