Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuxi init doesn't work when selecting yarn #273

Open
bmulholland opened this issue Nov 2, 2023 · 5 comments
Open

nuxi init doesn't work when selecting yarn #273

bmulholland opened this issue Nov 2, 2023 · 5 comments

Comments

@bmulholland
Copy link

bmulholland commented Nov 2, 2023

Environment


  • Operating System: Darwin
  • Node Version: v20.6.0
  • Nuxt Version: -
  • CLI Version: 3.9.1
  • Nitro Version: -
  • Package Manager: unknown
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

Run npx nuxi@latest init nuxt3

Select any package manager

Describe the bug

It crashes.

➤ YN0009: │ esbuild@npm:0.19.5 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/00/dd4ntv795rx101d_l6wnvdyc0000gn/T/xfs-3e1909f1/build.log)
➤ YN0009: │ esbuild@npm:0.18.20 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/00/dd4ntv795rx101d_l6wnvdyc0000gn/T/xfs-32f04585/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: /private/var/folders/00/dd4ntv795rx101d_l6wnvdyc0000gn/T/xfs-c9c03fa3/build.log)

logs are:

# This file contains the result of Yarn building a package (esbuild@npm:0.19.5)
# Script name: postinstall


node:internal/process/esm_loader:48
      internalBinding('errors').triggerUncaughtException(
                                ^
TypeError [Error]: [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "file:///Users/bmulholland/dev/recital/nuxt3/.yarn/unplugged/esbuild-npm-0.19.5-107ce8536d/node_modules/esbuild/package.json" needs an import assertion of type "json"
    at load$1 (file:///Users/bmulholland/dev/recital/nuxt3/.pnp.loader.mjs:1457:17)
    at nextLoad (node:internal/modules/esm/hooks:832:28)
    at Hooks.load (node:internal/modules/esm/hooks:415:26)
    at handleMessage (node:internal/modules/esm/worker:168:24)
    at checkForMessages (node:internal/modules/esm/worker:117:28)
    at process.<anonymous> (node:internal/modules/esm/worker:136:5)
    at process.emit (node:events:514:28)
    at process.emit (/Users/bmulholland/dev/recital/nuxt3/.pnp.cjs:18020:25) {
  code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING'
}

Node.js v20.6.0

Additional context

No response

Logs

No response

@bmulholland
Copy link
Author

bmulholland commented Nov 2, 2023

Found nodejs/help#4241. Tried Node 20.9.0 too. That fixed pnpm but not yarn.

Here's what pnpm showed on 20.6.0:

% npx nuxi@latest init nuxt3

✔ Which package manager would you like to use?
pnpm
◐ Installing dependencies...                                                                                                                                                                                                         5:16:53 p.m.
Packages: +685
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 738, reused 685, downloaded 0, added 685, done
node_modules/.pnpm/esbuild@0.19.5/node_modules/esbuild: Running postinstall script, done in 265ms
node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild: Running postinstall script, done in 166ms

> nuxt-app@ postinstall /Users/bmulholland/dev/recital/nuxt3
> nuxt prepare


 ERROR  Cannot redefine property: __internal__deprecationWarning                                                                                                                                                                     5:17:03 p.m.

  at Function.defineProperty (<anonymous>)
  at Object.<anonymous> (node_modules/.pnpm/@babel+types@7.23.0/node_modules/@babel/types/lib/index.js:66:8)
  at Module._compile (node:internal/modules/cjs/loader:1241:14)
  at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
  at Module.load (node:internal/modules/cjs/loader:1091:32)
  at Module._load (node:internal/modules/cjs/loader:938:12)
  at Module.require (node:internal/modules/cjs/loader:1115:19)
  at require (node:internal/modules/helpers:130:18)
  at Object.<anonymous> (node_modules/.pnpm/@babel+types@7.23.0/node_modules/@babel/types/lib/builders/validateNode.js:8:14)
  at Module._compile (node:internal/modules/cjs/loader:1241:14)



 ERROR  Cannot redefine property: __internal__deprecationWarning                                                                                                                                                                     5:17:03 p.m.

 ELIFECYCLE  Command failed with exit code 1.

 ERROR  Error: Command failed with exit code 1: corepack pnpm install

@bmulholland
Copy link
Author

bmulholland commented Nov 2, 2023

Looks like npm works with node 20.9 too. It's just yarn that doesn't

@bmulholland bmulholland changed the title nuxi init doesn't work nuxi init doesn't work when selecting yarn Nov 2, 2023
@danielroe danielroe transferred this issue from nuxt/nuxt Nov 2, 2023
@pi0
Copy link
Member

pi0 commented Nov 3, 2023

Hi dear @bmulholland. I am trying locally with Node 18.16, latest nuxi init seems to be working fine:

image

If you try with nuxi init --no-install, can you normally cd to the project and use yarn install?

➤ YN0009: │ esbuild@npm:0.19.5 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/00/dd4ntv795rx101d_l6wnvdyc0000gn/T/xfs-3e1909f1/build.log)

This seems about env build issue. Do you have more logs?

@bmulholland
Copy link
Author

bmulholland commented Nov 3, 2023

Hey @pi0! Nice to hear from you, hope you're well :). Thanks for the --no-install idea; that helped me track it down better. The problem arises when using Yarn Berry (I'm on 4.0.1). When using Yarn Classic (yarn set version classic), the install works fine. But if the active version is modern yarn (yarn set version stable), then the yarn install fails.

Also, BTW, if you use --no-install, cd to the dir, and set the yarn version to stable, 2/3 error messages go away -- but there's still an issue with nuxt/kit. I'm not going to dive into that here, this is already long enough :)

So, some thoughts:

If the generated project only works for yarn classic, then ideally the package.json would enforce that. There's ways to encode the yarn version in package.json, but actually it seems that's a feature only available in modern yarn, not yarn classic. Failing that, maybe the package manager prompt could be updated to say "yarn classic," not just "yarn"? It's not perfect but it's an improvement.

Alternatively, the generated project could be updated to work with the latest yarn. (Or maybe just add that as yet another option? :). The advantage here (aside from being the latest!) is that this version of yarn has ways to set the correct version in the package.json. I think the binary is also usually included in the repo? I recognized that all of this is a bit of a PITA.

(Re: the logs, I included the contents of one of the build logs: that's the second log snipped in the original post.)

BTW -- I'd originally searched when I thought the issue was just "init fails," and didn't find any matches. After I'd resolved the Node issue, that narrowed it down to Yarn, and I see there's related issues for that. e.g. #217. That may have tips on how to fix the project to work on the latest.

@madmonkey
Copy link

madmonkey commented Dec 6, 2023

I ran into this issue this morning.

I detailed my misadventures here:
https://stackoverflow.com/questions/77609733/initializing-a-base-nuxt-3-application-fails-to-run

EDIT: This seemed to work once - afterwards, I get the same failing result where the page fails to render. I've tried several things to try and rectify the issue including changing node versions. Since I can reproduce this on the regular @pi0 , I'd be more than happy to submit any kind of logs / information or otherwise that can help determine the underlying cause. I suspect it is something having to do with Windows/Vite - as a consistent error message is:
Uncaught SyntaxError: Cannot use 'import.meta' outside a module

image

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants