🧶
未解決: yarn4 で yarn create nuxt@latest が失敗する
概要
以下の環境にて yarn create nuxt@latest を実行するとエラーで失敗します。
- WSL
- nvm: 0.39.5, node: v22.18.0
- corepack: 0.34.0
- yarn: 4.9.2
エラー内容
$ yarn create nuxt@latest reka-ui-example
➤ YN0000: · Yarn 4.9.2
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + create-nuxt@npm:3.28.0, citty@npm:0.1.6, consola@npm:3.4.2
➤ YN0000: └ Completed in 0s 950ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 3 packages were added to the project (+ 6.3 MiB).
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: └ Completed
➤ YN0000: · Done with warnings in 1s 58ms
.d$b.
i$$A$$L .d$b
.$$F` `$$L.$$A$$.
j$$' `4$$:` `$$.
j$$' .4$: `$$.
j$$` .$$: `4$L
:$$:____.d$$: _____.:$$:
`4$$$$$$$$P` .i$$$$$$$$P`
ℹ Welcome to Nuxt! nuxi 1:13:00 PM
ℹ Creating a new project in reka-ui-example. nuxi 1:13:00 PM
✔ Which package manager would you like to use?
yarn
◐ Installing dependencies... nuxi 1:13:01 PM
➤ YN0000: · Yarn 4.9.2
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + nuxt@npm:4.0.3, vue-router@npm:4.5.1, vue@npm:3.5.18, @ampproject/remapping@npm:2.3.0, and 888 more.
➤ YN0000: └ Completed in 5s 322ms
➤ YN0000: ┌ Post-resolution validation
➤ YN0086: │ Some peer dependencies are incorrectly met by dependencies; run yarn explain peer-requirements for details.
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 0s 690ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ @parcel/watcher@npm:2.5.1 must be built because it never has been before or the last one failed
➤ YN0007: │ esbuild@npm:0.25.8 must be built because it never has been before or the last one failed
➤ YN0007: │ esbuild@npm:0.25.5 must be built because it never has been before or the last one failed
➤ YN0007: │ nuxt-app@workspace:. must be built because it never has been before or the last one failed
➤ YN0009: │ nuxt-app@workspace:. couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-11f11965/build.log)
➤ YN0000: └ Completed in 1s 354ms
➤ YN0000: · Failed with errors in 7s 479ms
ERROR Error: corepack yarn install failed. nuxi 1:13:09 PM
ログ:/tmp/xxx/build.log
# This file contains the result of Yarn building a package (nuxt-app@workspace:.)
# Script name: postinstall
ERROR Cannot resolve module "@nuxt/kit" (from: /home/xxx/application/javascript/reka-ui-example/)
...(省略)...
ERROR Cannot resolve module "@nuxt/kit" (from: /home/xxx/application/javascript/reka-ui-example/)
結局解決はしていない。ただ、わかったことはあったのでその時のことをメモしておきます😴😴😴
原因と解決方法
おそらく、yarn4 の機能の PnP(Plug'n'Play) が原因。一部のパッケージがこれに対応していないと思われる。
したがって、nodeLinker を node-modules に指定するなどすれば解決すると思われる。しかし、これは新規のプロジェクト立ち上げなので、どのようにグローバルな yarn を設定すればいいのかわからない。きっと何らかの設定方法はあるのだろうけど...😅😅😅
おそらく yarn を使うパターンでいちばん楽なのは、 npm でプロジェクトを立てる→ yarn に移行する、だと思う。しかし、そこまでして yarn を使うべきか?と葛藤した。→今回は諦めた。
Discussion