Symptoms
- The build fails on the server but not locally
- Errors about missing modules or files
- The app starts but crashes on some pages
- It worked last week and nothing seems to have changed
Why it happens
Your computer and the server are two different environments. They may run different versions of Node or PHP, have different settings, and treat file names differently.
AI tools write code against whatever is on your machine. They do not know what the server looks like, so the gaps only show up at deploy time.
Try this first
-
Match the Node version
Check which version you use locally and tell the server to use the same one.
node -v # save it for the project node -v > .nvmrc -
Commit the lock file
Make sure package-lock.json, yarn.lock or pnpm-lock.yaml is saved in your repository, so the server installs the same package versions you have.
-
Add the settings the server needs
Every environment variable your app reads locally from a .env file must also be set on the server. The .env file itself should not be in git.
-
Check capital letters in file names
Windows and macOS often ignore the difference between Header.jsx and header.jsx. Linux servers do not. Make the import match the file name exactly.
// File on disk: components/Header.jsx import Header from './components/header' // fails on Linux import Header from './components/Header' // works everywhere -
Read the server logs
The build and runtime logs on your host usually name the exact file and line. Start with the first error.
When to stop and call a person
Call a person if the server needs a different setup than your laptop, like a database, background jobs or a reverse proxy, or if you want a deploy pipeline that tests the app before it goes live.
Questions people ask
Why does it say a module is missing when it is installed?
Often the package was installed globally on your computer or never saved to package.json. Install it in the project so it is listed there.
Should I use Docker?
It helps keep environments the same, but it adds setup. For small apps, matching versions and settings is usually enough.