This still seems to be problematic.
If you have docker installed the reproduction should help you verify a proper fix going forward? Below is two failing cases and one that is successful with a bit of extra configuration (that nuxi init could configure).
⚡️ Nuxt Generation CLI Experience (nuxi v3.9.0)
Previous issues stating it had been resolved with 3.8:
Related issues on yarn support with nuxt:
❌ | Yarn 3.6.3 (defaults to nodeLinker: pnp)
ERROR Error: Command failed with exit code 1: corepack yarn install
# Reproducible nodejs environment:
$ docker run --rm -it --workdir /reproduction node:20-bookworm-slim bash
# Legacy yarn is global default:
$ yarn -vv1.22.19
# `yarn -v` will match any yarn version specified in the `packageManager` field of `package.json`:
$ corepack enable
# If a `package.json` is not present (or is missing `packageManager` field), this sets the fallback version:
# (_Still requires corepack to have been enabled to be applicable_)
$ corepack prepare yarn@stable --activate
$ yarn -v3.6.3
# Run `nuxi init` non-interactively via explicit options:
$ yarn dlx nuxi init --packageManager yarn --gitInit false.➤ YN0000: ┌ Resolution step➤ YN0032: │ fsevents@npm:2.3.3: Implicit dependencies on node-gyp are discouraged➤ YN0000: └ Completed in 2s 406ms➤ YN0000: ┌ Fetch step➤ 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 2s 606ms◐ Installing dependencies...➤ YN0000: ┌ Resolution step➤ YN0032: │ fsevents@npm:2.3.3: Implicit dependencies on node-gyp are discouraged➤ YN0032: │ @parcel/watcher@npm:2.3.0: Implicit dependencies on node-gyp are discouraged➤ YN0032: │ node-addon-api@npm:7.0.0: Implicit dependencies on node-gyp are discouraged➤ YN0002: │ nuxt-app@workspace:. doesn't provide vite (p73f11), requested by @nuxt/devtools➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code➤ YN0000: └ Completed in 6s 967ms➤ YN0000: ┌ Fetch step➤ YN0013: │ yaml@npm:2.3.2 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ yargs-parser@npm:21.1.1 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ yargs@npm:17.7.2 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ zhead@npm:2.1.1 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ zip-stream@npm:5.0.1 can't be found in the cache and will be fetched from the remote registry➤ YN0000: └ Completed in 1s 152ms➤ YN0000: ┌ Link step➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental➤ YN0007: │ esbuild@npm:0.18.20 must be built because it never has been before or the last one failed➤ YN0007: │ esbuild@npm:0.19.3 must be built because it never has been before or the last one failed➤ YN0009: │ esbuild@npm:0.18.20 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-797ad338/build.log)➤ YN0009: │ esbuild@npm:0.19.3 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-56d77649/build.log)➤ 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-8ee15c2e/build.log)➤ YN0000: └ Completed in 0s 646ms➤ YN0000: Failed with errors in 8s 813ms ERROR Error: Command failed with exit code 1: corepack yarn install
❌ | Yarn 1.22.19 (no PNP, uses node_modules)
error Couldn't find a package.json file in "/reproduction"
$ docker run --rm -it --workdir /reproduction node:20-bookworm-slim bash
# Fails (corepack is not enabled by default)
$ yarn dlx nuxi init --packageManager yarn --gitInit false.yarn run v1.22.19error Couldn't find a package.json file in "/reproduction"info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Try again (with corepack enabled):
ERROR Error: Command failed with exit code 1: corepack yarn install
$ docker run --rm -it --workdir /reproduction node:20-bookworm-slim bash
$ corepack enable
# `yarn dlx` will use a modern version of yarn to run,
# `nuxi init` will then run the global yarn which is still 1.22.19:
$ yarn dlx nuxi init --packageManager yarn --gitInit false.➤ YN0000: ┌ Resolution step➤ YN0032: │ fsevents@npm:2.3.3: Implicit dependencies on node-gyp are discouraged➤ YN0000: └ Completed in 2s 342ms➤ YN0000: ┌ Fetch step➤ YN0013: │ wide-align@npm:1.1.5 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ wrap-ansi@npm:7.0.0 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ wrap-ansi@npm:8.1.0 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ wrappy@npm:1.0.2 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ yallist@npm:4.0.0 can't be found in the cache and will be fetched from the remote registry➤ YN0000: └ Completed in 1s 331ms➤ YN0000: ┌ Link step➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental➤ YN0000: └ Completed➤ YN0000: Done with warnings in 3s 845ms◐ Installing dependencies...yarn install v1.22.19info No lockfile found.[1/4] Resolving packages...[2/4] Fetching packages...warning vscode-languageclient@7.0.0: The engine "vscode" appears to be invalid.[3/4] Linking dependencies...warning " > @nuxt/devtools@0.8.4" has unmet peer dependency "vite@*".warning "@nuxt/devtools > vite-plugin-inspect@0.7.38" has unmet peer dependency "vite@^3.1.0 || ^4.0.0".warning "@nuxt/devtools > vite-plugin-vue-inspector@3.7.1" has unmet peer dependency "vite@^3.0.0-0 || ^4.0.0-0".warning "@nuxt/devtools > @nuxt/devtools-kit@0.8.4" has unmet peer dependency "vite@*".[4/4] Building fresh packages...⠁⠁error An unexpected error occurred: "/reproduction/node_modules/@esbuild-kit/core-utils/node_modules/esbuild, /reproduction/node_modules/vite/node_modules/esbuild: Cannot find module 'pnpapi'Require stack:- /root/.cache/node/corepack/yarn/1.22.19/lib/cli.jsRequire stack:- /root/.cache/node/corepack/yarn/1.22.19/lib/cli.js". ERROR Error: Command failed with exit code 1: corepack yarn install
✔️ | Yarn 3.6.3 (change to nodeLinker: node-modules)
Installation completed.
Unless you have a way to resolve the issues above (Yarn project seems to want to keep legacy yarn as global by default, only using corepack to upgrade with yarn dlx and package.json approaches 🤷♂️ ), you may have to let users know to override the linker via ENV?
- When choosing
yarn you should probably set packageManager in package.json to ensure it installs with a newer version of yarn (when corepack is enabled). - Since Nuxt is not compatible with PnP linker, you'd additionally want to create a
.yarnrc.yml with nodeLinker: node-modules as a minimum. Once you've configured pacakge.json:packageManager (must be semver like yarn@3.6.3, cannot use yarn@stable), you can run yarn config set nodeLinker node-modules to do this (if easier than manually creating the file).
EDIT: PNPM support has a related workaround in nuxi init with creating a .npmrc file.
$ docker run --rm -it --workdir /reproduction node:20-bookworm-slim bash
# Requirement (user should already have applied via reading yarn install docs):
$ corepack enable
# Temporary workaround until`package.json:packageManager` is implemented:
$ corepack prepare yarn@stable --activate
# Temporary linker workaround with ENV (`yarn config` not usable until`package.json` exists):
$ YARN_NODE_LINKER=node-modules yarn dlx nuxi init --packageManager yarn --gitInit false.➤ YN0000: ┌ Resolution step➤ YN0032: │ fsevents@npm:2.3.3: Implicit dependencies on node-gyp are discouraged➤ YN0000: └ Completed in 3s 112ms➤ YN0000: ┌ Fetch step➤ YN0013: │ wide-align@npm:1.1.5 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ wrap-ansi@npm:7.0.0 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ wrap-ansi@npm:8.1.0 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ wrappy@npm:1.0.2 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ yallist@npm:4.0.0 can't be found in the cache and will be fetched from the remote registry➤ YN0000: └ Completed in 1s 302ms➤ YN0000: ┌ Link step➤ YN0000: └ Completed➤ YN0000: Done with warnings in 4s 562ms◐ Installing dependencies...➤ YN0000: ┌ Resolution step➤ YN0032: │ fsevents@npm:2.3.3: Implicit dependencies on node-gyp are discouraged➤ YN0032: │ @parcel/watcher@npm:2.3.0: Implicit dependencies on node-gyp are discouraged➤ YN0032: │ node-addon-api@npm:7.0.0: Implicit dependencies on node-gyp are discouraged➤ YN0002: │ nuxt-app@workspace:. doesn't provide vite (p73f11), requested by @nuxt/devtools➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code➤ YN0000: └ Completed in 9s 776ms➤ YN0000: ┌ Fetch step➤ YN0013: │ yaml@npm:2.3.2 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ yargs-parser@npm:21.1.1 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ yargs@npm:17.7.2 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ zhead@npm:2.1.1 can't be found in the cache and will be fetched from the remote registry➤ YN0013: │ zip-stream@npm:5.0.1 can't be found in the cache and will be fetched from the remote registry➤ YN0000: └ Completed in 5s 537ms➤ YN0000: ┌ Link step➤ YN0007: │ esbuild@npm:0.19.3 must be built because it never has been before or the last one failed➤ YN0007: │ esbuild@npm:0.18.20 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➤ YN0000: └ Completed in 4s 253ms➤ YN0000: Done with warnings in 19s 677ms✔ Installation completed.✨ Nuxt project has been created with the v3 template. Next steps: › Start development server with yarn run dev
NOTE:yarn dlx is not a great experience with nuxi since each time yarn takes about 4 seconds to prepare 🙄 (more of an issue with how yarn works, nothing to do with nuxi AFAIK)
Until nuxi init handles the additional yarn support changes. Users should:
- Add the
packageManager field to package.json (better portability). - Run
yarn config set nodeLinker: node-modules (avoid requiring an ENV to override).
`yarn build` is successful
Important, since you can use yarn install in some nuxt project that is successful (with nodeLinker: pnp) but fails with yarn build.
$ YARN_NODE_LINKER=node-modules yarn buildNuxt 3.7.3 with Nitro 2.6.3ℹ Building client...ℹ vite v4.4.9 building for production...ℹ ✓ 112 modules transformed.ℹ .nuxt/dist/client/manifest.json 1.59 kB │ gzip: 0.31 kBℹ .nuxt/dist/client/_nuxt/error-500.c5df6088.css 1.95 kB │ gzip: 0.74 kBℹ .nuxt/dist/client/_nuxt/error-404.7fc72018.css 3.63 kB │ gzip: 1.12 kBℹ .nuxt/dist/client/_nuxt/entry.3c4ebcd6.css 12.13 kB │ gzip: 2.49 kBℹ .nuxt/dist/client/_nuxt/error-500.e5a1dd9d.js 1.88 kB │ gzip: 0.99 kBℹ .nuxt/dist/client/_nuxt/error-404.d5f8e506.js 6.53 kB │ gzip: 2.91 kBℹ .nuxt/dist/client/_nuxt/entry.8be7e620.js 197.90 kB │ gzip: 55.68 kBℹ ✓ built in 1.07s✔ Client built in 1083msℹ Building server...ℹ vite v4.4.9 building SSR bundle for production...ℹ ✓ 61 modules transformed.ℹ .nuxt/dist/server/_nuxt/entry-styles.8755339a.mjs 0.08 kBℹ .nuxt/dist/server/_nuxt/error-404-styles.1e0dde27.mjs 0.15 kBℹ .nuxt/dist/server/_nuxt/error-500-styles.cf4b3e80.mjs 0.15 kBℹ .nuxt/dist/server/styles.mjs 0.46 kBℹ .nuxt/dist/server/_nuxt/island-renderer-bc39a2f4.js 1.06 kB │ map: 1.38 kBℹ .nuxt/dist/server/_nuxt/error-500-styles-1.mjs-8fa81fcc.js 2.17 kB │ map: 0.12 kBℹ .nuxt/dist/server/_nuxt/error-500-57cb52a6.js 3.03 kB │ map: 3.77 kBℹ .nuxt/dist/server/_nuxt/error-404-styles-1.mjs-e0837f4f.js 3.86 kB │ map: 0.12 kBℹ .nuxt/dist/server/_nuxt/error-404-3dc619ae.js 9.70 kB │ map: 18.97 kBℹ .nuxt/dist/server/_nuxt/entry-styles-1.mjs-8b8449e7.js 12.38 kB │ map: 0.11 kBℹ .nuxt/dist/server/server.mjs 120.84 kB │ map: 163.36 kBℹ ✓ built in 536ms✔ Server built in 543ms✔ Generated public .output/publicℹ Building Nitro Server (preset: node-server)✔ Nitro server built ├─ .output/server/chunks/app/_nuxt/entry-styles.8755339a.mjs (12.4 kB) (2.61 kB gzip) ├─ .output/server/chunks/app/_nuxt/entry-styles.8755339a.mjs.map (312 B) (202 B gzip) ├─ .output/server/chunks/app/_nuxt/error-404-3dc619ae.mjs (9.81 kB) (3.12 kB gzip) ├─ .output/server/chunks/app/_nuxt/error-404-3dc619ae.mjs.map (8.02 kB) (1.97 kB gzip) ├─ .output/server/chunks/app/_nuxt/error-404-styles.1e0dde27.mjs (3.98 kB) (1.25 kB gzip) ├─ .output/server/chunks/app/_nuxt/error-404-styles.1e0dde27.mjs.map (346 B) (215 B gzip) ├─ .output/server/chunks/app/_nuxt/error-500-57cb52a6.mjs (3.07 kB) (1.35 kB gzip) ├─ .output/server/chunks/app/_nuxt/error-500-57cb52a6.mjs.map (1.68 kB) (600 B gzip) ├─ .output/server/chunks/app/_nuxt/error-500-styles.cf4b3e80.mjs (2.28 kB) (870 B gzip) ├─ .output/server/chunks/app/_nuxt/error-500-styles.cf4b3e80.mjs.map (346 B) (217 B gzip) ├─ .output/server/chunks/app/_nuxt/island-renderer-bc39a2f4.mjs (1.17 kB) (525 B gzip) ├─ .output/server/chunks/app/_nuxt/island-renderer-bc39a2f4.mjs.map (897 B) (413 B gzip) ├─ .output/server/chunks/app/client.manifest.mjs (2.52 kB) (461 B gzip) ├─ .output/server/chunks/app/client.manifest.mjs.map (2.04 kB) (405 B gzip) ├─ .output/server/chunks/app/server.mjs (123 kB) (23.7 kB gzip) ├─ .output/server/chunks/app/server.mjs.map (220 B) (164 B gzip) ├─ .output/server/chunks/app/styles.mjs (533 B) (269 B gzip) ├─ .output/server/chunks/app/styles.mjs.map (429 B) (216 B gzip) ├─ .output/server/chunks/error-500.mjs (4.26 kB) (1.82 kB gzip) ├─ .output/server/chunks/error-500.mjs.map (193 B) (157 B gzip) ├─ .output/server/chunks/handlers/renderer.mjs (12.9 kB) (4.08 kB gzip) ├─ .output/server/chunks/handlers/renderer.mjs.map (424 B) (227 B gzip) ├─ .output/server/chunks/multipart-parser.mjs (5.04 kB) (2.1 kB gzip) ├─ .output/server/chunks/multipart-parser.mjs.map (210 B) (167 B gzip) ├─ .output/server/chunks/nitro/node-server.mjs (260 kB) (66.5 kB gzip) ├─ .output/server/chunks/nitro/node-server.mjs.map (3.21 kB) (834 B gzip) ├─ .output/server/chunks/rollup/_virtual_spa-template.mjs (94 B) (100 B gzip) ├─ .output/server/chunks/rollup/_virtual_spa-template.mjs.map (112 B) (112 B gzip) ├─ .output/server/index.mjs (389 B) (210 B gzip) └─ .output/server/package.json (708 B) (294 B gzip)
Σ Total size: 2.33 MB (558 kB gzip)✔ You can preview this build using node .output/server/index.mjs
This still seems to be problematic.
If you have docker installed the reproduction should help you verify a proper fix going forward? Below is two failing cases and one that is successful with a bit of extra configuration (that
nuxi initcould configure).Previous issues stating it had been resolved with 3.8:
Related issues on yarn support with nuxt:
node-moduleslinker nuxt#22861 (comment)--shamefully-hoistnuxt#14146 (comment)❌ | Yarn 3.6.3 (defaults to
nodeLinker: pnp)❌ | Yarn 1.22.19 (no PNP, uses
node_modules)Try again (with corepack enabled):
✔️ | Yarn 3.6.3 (change to
nodeLinker: node-modules)Unless you have a way to resolve the issues above (Yarn project seems to want to keep legacy yarn as global by default, only using corepack to upgrade with
yarn dlxandpackage.jsonapproaches 🤷♂️ ), you may have to let users know to override the linker via ENV?yarnyou should probably setpackageManagerinpackage.jsonto ensure it installs with a newer version of yarn (when corepack is enabled)..yarnrc.ymlwithnodeLinker: node-modulesas a minimum. Once you've configuredpacakge.json:packageManager(must be semver likeyarn@3.6.3, cannot useyarn@stable), you can runyarn config set nodeLinker node-modulesto do this (if easier than manually creating the file).EDIT: PNPM support has a related workaround in
nuxi initwith creating a.npmrcfile.NOTE:
yarn dlxis not a great experience withnuxisince each time yarn takes about 4 seconds to prepare 🙄 (more of an issue with how yarn works, nothing to do withnuxiAFAIK)Until
nuxi inithandles the additional yarn support changes. Users should:packageManagerfield topackage.json(better portability).yarn config set nodeLinker: node-modules(avoid requiring an ENV to override).`yarn build` is successful
Important, since you can use
yarn installin some nuxt project that is successful (withnodeLinker: pnp) but fails withyarn build.