Skip to content

Conversation

cprecioso
Copy link
Member

@cprecioso cprecioso commented Sep 18, 2025

Made as part of


There is an interaction when running npx in an inner folder of subpackage in an npm workspace:

  • my-project/
    • package.json (has workspaces: ["sub-project"])
    • sub-project/
      • package.json
      • build/
        • index.html
        • etc

Doing the following:

cd sub-project/build
npx serve

Will call serve with the cwd set to sub-project and not build. npx detects it's in a workspace environment, and then works extra hard to find the current package root, and run the program there (same as if you were doing npm run build, which runs in the package root). But in this case it will serve an incorrect directory.

To adapt ourselves to the new behaviour, we explicitly tell npx serve the location of the folder we want it to run.


I send this PR ahead of time because the wasp-app-runner used for E2E examples is taken from npm, so we should do this change first and then publish so that #3159 can pass the tests. (I made an issue at #3169 to address that at some point)

Comment on lines 70 to 73
args: ["serve", "--single", "-p", "3000"],
cwd: path.join(pathToApp, clientAppBuildOutputDir),
args: ["serve", "--single", "-p", "3000", servePath],
cwd: servePath,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace npx serve with npm run preview since this is what you ended up doing in wasp start build? (even better, we just call wasp start build in the future)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be npm run preview -- --port 3000 --strictPort I guess

Copy link
Contributor

@infomiho infomiho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go go go

@cprecioso cprecioso merged commit 8b8b0ab into main Sep 18, 2025
2 checks passed
@cprecioso cprecioso deleted the cprecioso/fix-wasp-app-runner branch September 18, 2025 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants