A bunch of deployment only errors
I have my a branch on my repo that doesn't produce any errors in dev, but produces a few notable errors when building. Some of these errors include:
even though
jose
is specifically installed in my package.json
and
Any help figuring these out would be greatly appreciated.GitHub
GitHub - Kaympe20/AllCash at auth
A completely FOSS EveryDollar alternative. Contribute to Kaympe20/AllCash development by creating an account on GitHub.
6 Replies
Hi @Kaympe. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Your deployment-only errors are common in Nuxt projects, especially when dependencies or build environments differ between development and production. Here’s what the knowledge sources suggest for similar issues:
1. "Cannot find package 'jose'" (or other modules) in production
This usually happens when a dependency is present in your
package.json
but is not actually installed in the production environment. In Nuxt, especially with server-side code, you must ensure all dependencies required at runtime are listed under "dependencies"
(not "devDependencies"
), as only these are installed in production builds. One user fixed a similar issue by moving all packages from devDependencies
to dependencies
and reinstalling everything before deployment. Also, deleting node_modules
and lock files before a fresh install can help resolve missing modules in production builds Deploy Nuxt3 to AppEngine Standard or Felxible Environment.
2. Native module errors (e.g., bcrypt, sharp, or "napi_register_module_v1" not found)
Native modules like bcrypt
or sharp
often fail in production if they are built for a different environment than your deployment target. This can happen if you build locally (e.g., on macOS) and deploy to Linux, or if Docker is not used consistently. The recommended approach is to build your app in the same environment as your production server, ideally using Docker. If you use Docker, make sure you do not mount your local code over the container’s /app
directory in production, as this can overwrite the built .output
folder and cause "Cannot find module" errors How to run Nuxt3 with docker (docker compose).
3. General "Cannot find module" errors in Docker/Nuxt
If you see errors like "Cannot find module '/app/.output/server/index.mjs'", it’s often due to Docker volumes overwriting the build output, or the build step not running in the correct environment. Removing unnecessary volumes in your Docker Compose file for production, and ensuring the build happens inside the container, usually resolves this How to run Nuxt3 with docker (docker compose) Docker Build Problem "Error: Cannot find module".
4. Error handling in Nuxt API routes
Nuxt’s error handling in API routes has improved over time. In older versions, thrown errors in API routes could leak sensitive information. In recent versions, unhandled errors return a generic message. If you see detailed error messages in production, ensure you’re using an up-to-date Nuxt version API route leak content of errors.
---
Summary of steps to resolve:
- Move all runtime dependencies (like jose
, openid-client
, bcrypt
) to "dependencies"
in package.json
.
- Delete node_modules
and lock files, then reinstall (npm install
or pnpm install
).
- Build your app in the same environment as your production server (use Docker if possible).
- For native modules, ensure they are built for the correct platform.
- Avoid mounting local folders over /app
in Docker production.
- Update Nuxt to the latest version to benefit from improved error handling.
If you follow these steps and still encounter issues, please provide your Dockerfile, deployment process, and a list of dependencies for more targeted help.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@927001807815868436> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai I have already done all of these
Let me check the knowledge base for you again. One moment! :books:
----------------------
Thank you for clarifying that you've already tried the standard solutions. Based on the knowledge sources provided, here are some additional, more nuanced points and observations that may help:
---
1. Native Module Errors (e.g., bcrypt, sharp, node-gyp-build)
The error involving
napi_register_module_v1
and node-gyp-build
suggests a native module binary mismatch. In a similar case with the sharp module, the solution was to rebuild the native module specifically for the target environment using:
This approach may also apply to other native modules like bcrypt. If you are deploying to a Linux server (especially Alpine or musl-based), ensure you rebuild all native modules in the production environment after installing dependencies nuxt/image module in nuxt 3 causes problem in production.
---
2. Docker and Volumes
If you are using Docker, mounting your local directory as a volume in production can overwrite the built .output
directory, causing "Cannot find module" errors. One user resolved this by removing the volume mounts in their production Docker Compose file, which allowed the container to use the correct build output How to run Nuxt3 with docker (docker compose).
---
3. .dockerignore and node_modules
Copying your local node_modules
into the container can cause dependency mismatches. Ensure you have a proper .dockerignore
file that excludes node_modules
so that dependencies are installed fresh inside the container Docker Build Problem "Error: Cannot find module".
---
4. Unexplained Build/Output Issues
There are cases where the .output
folder remains empty or the build does not behave as expected, even when everything seems correct. In one such case, the user resolved it by creating a brand new Nuxt project and carefully copying files over, suggesting that subtle configuration or file corruption can sometimes be the culprit Nuxt3 build .output folder remains empty, nothing copied from .nuxt.
---
5. Dependency Resolution in Monorepos
If you are using a monorepo or Turborepo, ensure the Docker build context includes all necessary files and packages. Missing context can cause missing dependencies at build time How to dockerize a nuxt project inside Turborepo?.
---
If All Else Fails
The knowledge sources do not provide a definitive solution beyond these points. If you have already rebuilt native modules, ensured correct dependencies, and checked Docker configuration, but the errors persist, the issue may be highly specific to your environment or project setup. In such cases, starting from a fresh Nuxt project and incrementally adding your code (as one user did) may help isolate the problem.
---
I'm sorry, but the knowledge sources do not contain a more specific solution for your situation beyond these steps. If you can share more details about your deployment environment or a minimal reproduction, it may help to further diagnose the issue.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@927001807815868436> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
edit: I should ask, fails to build on Github Actions or in your deployment provider?
Hi. Did you make sure your github yaml file installs a package manager and then installs depencies?
something like this:
Oh, I just read your README... not sure if you've seen Actual Budget, but I think that might be what you're looking for.