0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AstroでWorker is not definedエラーの対処法

Last updated at Posted at 2024-02-24

AstroでReactコンポーネントを使用時に下記のエラーが出た場合の対処法になります。

Workeris not defined

ReactコンポーネントでWorkeris not definedエラー

index.astro
<MyComponent />

AstroファイルでReactコンポーネントを読み込むと下記のエラー出てビルドできませんでした。

Astro Worker is not defined.png

Workeris not defined

Could not open checkImageBitmap.worker.js in the editor.
The editor process exited with an error: spawn code ENOENT.

Reactコンポーネント内でライブラリ(pixi.js)を使っており、そのライブラリの影響かと思われます。

client:only="react"の指定を追加して解決

index.astro
<MyComponent client:only="react"/>

呼び出し側のastroファイルでclient:only="react"を指定することで解決しました。

参考

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?