Cannot find package 'wasp' imported from /app/.wasp/build/server/bundle/server.js
CapRover
7 Replies
Hi @初九. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The error "Cannot find package 'wasp' imported from /app/.wasp/build/server/bundle/server.js" typically means that the generated server code is trying to import the Wasp SDK as a package named wasp, but that package is not present in your node_modules during deployment.
Based on the knowledge sources, here are some relevant points:
- Wasp generates SDK code that is expected to be available as a package (sometimes as wasp, sometimes as @wasp/*) in node_modules. If this package is missing, imports like import ... from 'wasp' will fail with the error you are seeing.
- This can happen if the Wasp build process did not correctly generate or install the SDK package into node_modules before deployment, or if the deployment process (e.g., on CapRover) does not include the generated SDK files in the build output.
- There have been discussions about how Wasp organizes and installs its SDK, including using local paths in package.json to point to the generated SDK inside the .wasp directory. For example:
This ensures that the SDK is available as a local package during build and deployment processes, but if this step is missed or misconfigured, the error can occur Figure out Wasp's
node_modules
story.
- A common solution when encountering missing modules or SDK issues is to run:
This will clean up the .wasp and node_modules folders and regenerate everything, which often resolves missing SDK/package issues Hey! Any ideas on some solutions to these errors?.
- When deploying, make sure that the build process includes the .wasp/build directory and that node_modules contains the generated wasp SDK package. If you are using Docker or a similar deployment method, ensure that the build steps in your Dockerfile or deployment script run wasp build and npm install in the correct order and context.
If after these steps the issue persists, it may be related to how CapRover builds and deploys your app, possibly not including the generated SDK or not running the necessary build steps. Double-check your deployment configuration to ensure all Wasp build steps are executed and the generated SDK is present in the deployed environment.
If you need more specific help, please provide details about your deployment process and Wasp version.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @初九, 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?server@0.0.0 start-production npm run db-migrate-prod && NODE_ENV=production npm run start
server@0.0.0 db-migrate-prod prisma migrate deploy --schema=../db/schema.prismaPrisma schema loaded from ../db/schema.prisma Datasource "db": PostgreSQL database "postgres", schema "public" at "srv-captain--uuvvuu-db:5432" 7 migrations found in prisma/migrations No pending migrations to apply.
server@0.0.0 start node --enable-source-maps -r dotenv/config bundle/server.jsnode:internal/errors:496 ErrorCaptureStackTrace(err); ^ Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'wasp' imported from /app/.wasp/build/server/bundle/server.js at __node_internal_captureLargerStackTrace (node:internal/errors:496:5) at new NodeError (node:internal/errors:405:5) at packageResolve (node:internal/modules/esm/resolve:890:9) at moduleResolve (node:internal/modules/esm/resolve:939:20) at defaultResolve (node:internal/modules/esm/resolve:1132:11) at nextResolve (node:internal/modules/esm/loader:163:28) at ESMLoader.resolve (node:internal/modules/esm/loader:835:30) at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18) at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40) at link (node:internal/modules/esm/module_job:76:36) { code: 'ERR_MODULE_NOT_FOUND' } Node.js v18.18.0 npm notice npm notice New major version of npm available! 9.8.1 -> 11.4.1 npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.4.1 npm notice Run
npm install -g npm@11.4.1
to update!
npm noticeWohooo @初九, you just became a Waspeteer level 1!
Help me, my English is not good, I may not express myself clearly, if you don't understand, you can always ask me
Hey @初九, we'll need more info on this I'm afriad
Are you using the latest version of Wasp?
Using 0.16.0
I updated to 0.16.4 and it works fine
Great to hear!