Nuxt での開発時に起こったエラーの修正方法
Yarn generate を Cloudflare Pages で使った場合に Error:1 でビルドが終了する
2022
SSG書き出しで、ビルドがコケる
bash
$ yarn generate
<TIMESTAMP> Cloning repository...
<TIMESTAMP> From <GITHUB REPO>
<TIMESTAMP> * branch <BRANCH> -> FETCH_HEAD
<TIMESTAMP>
<TIMESTAMP> HEAD is now at <COMMIT>
<TIMESTAMP>
<TIMESTAMP>
<TIMESTAMP> Success: Finished cloning repository files
<TIMESTAMP> Detected the following tools from environment: [email protected], [email protected]
<TIMESTAMP> Installing project dependencies: yarn
<TIMESTAMP> ➤ YN0070: Migrating from Yarn 1; automatically enabling the compatibility node-modules linker 👍
<TIMESTAMP>
<TIMESTAMP> ➤ YN0000: ┌ Resolution step
<TIMESTAMP> ➤ YN0032: │ fsevents@npm:2.3.3: Implicit dependencies on node-gyp are discouraged
<TIMESTAMP> ➤ YN0002: │ @algolia/autocomplete-core@npm:1.9.3 doesn't provide @algolia/client-search (pbc410), requested by @algolia/autocomplete-shared
<TIMESTAMP> ➤ YN0002: │ @algolia/autocomplete-core@npm:1.9.3 doesn't provide algoliasearch (p8ad5b), requested by @algolia/autocomplete-shared
<TIMESTAMP> ➤ YN0002: │ @algolia/autocomplete-core@npm:1.9.3 doesn't provide search-insights (pfdb70), requested by @algolia/autocomplete-plugin-algolia-insights
<TIMESTAMP> ➤ YN0002: │ @algolia/autocomplete-plugin-algolia-insights@npm:1.9.3 [e43f4] doesn't provide @algolia/client-search (pdf3b9), requested by @algolia/autocomplete-shared
<TIMESTAMP> ➤ YN0002: │ @algolia/autocomplete-plugin-algolia-insights@npm:1.9.3 [e43f4] doesn't provide algoliasearch (p0f6bb), requested by @algolia/autocomplete-shared
<TIMESTAMP> ➤ YN0002: │ @docsearch/react@npm:3.5.2 [0caf1] doesn't provide @algolia/client-search (paf512), requested by @algolia/autocomplete-preset-algolia
<TIMESTAMP> ➤ YN0002: │ @vueuse/core@npm:10.3.0 doesn't provide vue (pc399a), requested by vue-demi
<TIMESTAMP> ➤ YN0002: │ @vueuse/integrations@npm:10.3.0 [1ed4e] doesn't provide vue (p29731), requested by vue-demi
<TIMESTAMP> ➤ YN0002: │ @vueuse/shared@npm:10.3.0 doesn't provide vue (pc4ec3), requested by vue-demi
<TIMESTAMP> ➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
<TIMESTAMP> ➤ YN0000: └ Completed in 2s 869ms
<TIMESTAMP> ➤ YN0000: ┌ Post-resolution validation
<TIMESTAMP> ➤ YN0028: │ The lockfile would have been modified by this install, which is explicitly forbidden.
<TIMESTAMP> ➤ YN0000: └ Completed
<TIMESTAMP> ➤ YN0000: Failed with errors in 2s 891ms
<TIMESTAMP> Error: Exit with error code: 1
<TIMESTAMP> at ChildProcess.<anonymous> (/snapshot/dist/run-build.js)
<TIMESTAMP> at Object.onceWrapper (node:events:652:26)
<TIMESTAMP> at ChildProcess.emit (node:events:537:28)
<TIMESTAMP> at ChildProcess._handle.onexit (node:internal/child_process:291:12)
<TIMESTAMP> Failed: build command exited with code: 1
<TIMESTAMP> Failed: error occurred while running build command
使用しているパッケージは最低限これだけでした
bash
"vitepress": "^1.0.0-rc.4",
"vue": "^3.3.4"
Cloudflare Pages の ビルドシステムのバージョン 2 では Yarn 3 に 自動で
migrate
これは Vercel や Netlify などでは発生しない(謎)
とりあえず、環境変数に
変数名:
YARN_VERSION
1.22.19
を設定するとビルドが成功するようになった
Yarn 3 に移行したほうがいいんですかね……
init 使うとかPnPが失敗するとかであんまり使いたくない
なんであんなエラーばっかり出てしまうのか、、
軽くトラウマなので、しばらくは pnpm とかを使います
このページの情報は以上です