Production Build Issue After Upgrading to WASP 0.17.1
After upgrading to WASP 0.17.1, I'm experiencing issues starting my application in production environment. Th the server build fails.
When running the production build, I get the following error during the npm run bundle command:
The error suggests that development dependencies are not being installed in the production environment. I'm running this in a Docker environment. The Dockerfile is attached below for reference.
Is this a known issue with WASP 0.17.1?
Should development dependencies be installed in production for the bundle process?
Are there any changes needed in the Docker configuration for this version?
Any help would be greatly appreciated!
2 Replies
Hi @mario.p. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information in the knowledge sources, your issue is related to how development dependencies (like TypeScript, which provides the tsc command) are handled during the production build process in Wasp.
Should devDependencies be installed in production for the bundle process?
Yes, for the bundle process (specifically npm run bundle, which runs tsc and rollup), devDependencies like TypeScript must be available. The error bash: tsc: command not found indicates that tsc (TypeScript) is not installed in the environment where npm run bundle is executed. This typically happens if npm install is run with the --production flag or NODE_ENV=production, which skips devDependencies.
This is a known area of concern in Wasp's build process. There is an open issue discussing that Wasp does not currently distinguish between devDependencies and regular dependencies during the build, and that TypeScript (a devDependency) is required for the production build step (the bundle process) but should not be needed at runtime. The current approach is to always install all dependencies, including devDependencies, before bundling, and only exclude them in the final runtime image. This is necessary because the build step (npm run bundle) requires devDependencies like tsc and rollup to be present. See the discussion here: Fix how we build generated project for production (dev deps).
Is this a known issue with WASP 0.17.1?
Yes, this is a known issue and is being tracked. The Wasp team is aware that the build process requires devDependencies for the bundle step, and there is ongoing work to improve this. The current workaround is to ensure that devDependencies are installed during the build stage, even in production Docker builds, and only excluded from the final runtime image.
Are there any changes needed in the Docker configuration for this version?
Your Dockerfile should ensure that devDependencies are installed during the build stage. This means you should not use npm install --production or set NODE_ENV=production before the npm run bundle step. Only after the bundle step should you optimize the image for production by excluding devDependencies.
Your current Dockerfile appears to be correct in this regard, as it runs npm install (which installs all dependencies) before running npm run bundle. The error you are seeing may indicate that, for some reason, devDependencies are still not being installed, or that the working directory/context is not as expected.
Key points to check:
- Ensure that package.json lists TypeScript and other build tools as devDependencies.
- Make sure that npm install is not being run with --production or with NODE_ENV=production before the bundle step.
- The final runtime image can use NODE_ENV=production and exclude devDependencies, but the build image must have them.
Summary
- The build process (npm run bundle) requires devDependencies.
- This is a known issue and is being tracked by the Wasp team.
- Your Dockerfile should install devDependencies during the build stage, and only exclude them in the final runtime image.
- No major changes are needed in your Dockerfile for Wasp 0.17.1, but ensure you are not skipping devDependencies before the bundle step.
For more details, see the related issue: Fix how we build generated project for production (dev deps).
If you continue to have issues, double-check the build context and ensure that the correct package.json and node_modules are present at each step. If you have customized the Dockerfile, make sure it matches the structure expected by Wasp's build process.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @mario.p, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
Hey @mario.p, this is certainly a new issue.
I suppose you did do all of the migration steps for
0.17.1
or else you wouldn't have been able to run the application.
https://wasp.sh/docs/migration-guides/migrate-from-0-16-to-0-17
So normal wasp start
works?
Did you try to maybe clean the project first?
wasp clean
and then wasp build
?
You get the error while building the Docker image?