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

runCommand ignores cwd argument on versions after 3.6 #274

Closed
mandarini opened this issue Nov 3, 2023 · 5 comments · Fixed by #275
Closed

runCommand ignores cwd argument on versions after 3.6 #274

mandarini opened this issue Nov 3, 2023 · 5 comments · Fixed by #275
Labels
bug Something isn't working

Comments

@mandarini
Copy link
Contributor

Here is my reproduction repository: https://github.com/mandarini/nuxi-bug

Using "nuxi": "^3.9.1" and runCommand("dev", ["my-nuxt-app"]), runCommand ignores the name of the project (the directory), and runs the command in the root directory.

I would expect this to work exactly like running:

npx nuxi dev my-nuxt-app

If you run the above command, you will see that it works as expected.

If you run

npx tsx run-nuxt.ts

you will see that it does not pick up the directory, and runs the command in the root directory, it shows the default Nuxt template, instead of "Hello from Katerina".

More info in the README of my reproduction repository.

At Nx we will be using version 3.6.5, which is before citty was introduced. Same version is used by @nxext/nuxt plugin.

I think that there's an issue with citty losing some arguments in this case. But maybe I am wrong.

@pi0 pi0 added the bug Something isn't working label Nov 3, 2023
@pi0
Copy link
Member

pi0 commented Nov 3, 2023

Thanks for reporting issue.

It seems an issue with programmatic API not applying current root dir to the forked process.

As a solution, you might pass --no-fork argument:

await runCommand('dev', ['playground', '--no-fork'])

@pi0
Copy link
Member

pi0 commented Nov 3, 2023

Resolved in nuxi-nightly and next release.

@mandarini
Copy link
Contributor Author

Wow THANK YOU!

@mandarini
Copy link
Contributor Author

@pi0

when I use --no-fork I get the following error:

Nuxt 3.8.0 with Nitro 2.7.2

  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

[1:20:17 PM]   ➜ DevTools: press Shift + Option + D in the browser (v1.0.0)


[1:20:18 PM]  ERROR  __name is not defined


[1:20:19 PM]  ERROR  __name is not defined (x2)


[1:20:19 PM]  ERROR  __name is not defined (x3)

[1:20:19 PM] ℹ Vite client warmed up in 467ms
[nitro 1:20:19 PM] ✔ Nitro built in 303 ms
^C%                                                               

I'll try the nuxi-nightly and see!

@mandarini
Copy link
Contributor Author

@pi0 YES using "nuxi": "npm:nuxi-nightly@latest" works! THANKS!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants