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?

Amplify Gen2 + Nuxt3 デプロイ時にビルドで Error: Cannot find module '@rollup/rollup-darwin-x64' になる場合

Last updated at Posted at 2025-03-25

結論

ないなら追加すれば良い。ただし dependencies や devDependencies ではなく optionalDependencies として @rollup/rollup-darwin-x64 を追加すべき。 具体的にpackage.jsonに追加すべき項目を書くと、下記のようになる。

package.json
  "optionalDependencies": {
    "@rollup/rollup-linux-x64-gnu": "4.9.1"
  }

するとAmplify Gen2 + Nuxt3 のビルドが通って、無事にデプロイできるようになる。

解説:なぜ optionalDependencies として追加すべきなのか

  • Rollup のネイティブバイナリはOSごとに異なる
  • だから、環境を統一するか、環境差異を許容できるようにしないとエラーになる
  • そこで optionalDependencies の登場。optionalDependencies は dependencies や devDependencies と異なり、インストールに失敗してもエラーとならずスキップされる
  • これにより今回のRollupバイナリのような 「特定の環境下でのみインストールされてほしい」 「他の環境では互換性の問題でインストールできないのでスキップされてほしい」 という課題を解決してくれる
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?