Nicholas Agwah’s Post

npm run dev vs npm run build — My Humbling Lesson As a junior dev, I used to think: “If my app spins up and the terminal is green ✅ — I’m good. Zero bugs.” Then reality hit… Working on a production project, I pushed changes, opened a PR, feeling confident. Suddenly — got that weird message! 💥 “Hey bro, your changes broke the CI pipeline.” Me? Impossible. My terminal was green! I even tried to deny it at first Then my teammate calmly said: “Run npm run build and check again.” Boom. Errors everywhere. Unused variables. Lingering logs. Stuff I thought didn’t matter “for now.” Lesson learned ✅ npm run dev helps you develop ✅ npm run build tells you if your code can survive the real world Now before pushing any code: - npm run build - clean up - lint & fix 🧹 Every. Single. Time. If you're starting out — don’t trust only the green dev console Your future self (and your team) will thank you! 💡 Takeaway If it works on your machine but not in CI/CD, the problem is probably not CI/CD… it’s your build. #webdevelopment #frontend #javascript #reactjs #nextjs #cleanCode #softwareengineering #devlife #learninginpublic #techjourney #npm #typescript #juniorToSenior

  • text

I was a victim of this too. Everything worked perfectly on my local, but I didn’t run npm run build before pushing and merging into the dev branch. When my team lead called, he said, ‘Can you guys always run a build before pushing and creating a PR? I’ve literally been debugging all day.’ That was when I realized he was referring to me 😹. Since then, I always run a build before testing on local. 😄 Sometimes it’s good to learn the hard way but definitely not on products or projects already in production 😅.

I learnt this the hard way with next js. I built the project for two months, my first real next js project. Never run the build command, after completion, I tried running the build, I got close to a 1000 errors and warnings😂😂. Since then, I run build after each successful feature implementation or code change.

npm run build is just as important as anything else. npm run dev is lenient, it skips rules that your production build won’t forgive. Think of it like this: npm run dev is a kid in preschool, mistakes slide because it’s still learning. npm run build is university, every error counts, and you answer to it. It’s your real test, mimicking how your app behaves in live production.

Every project should have eslint implemented. Most of these issue are just solved because you have eslint configured. And run lint before every commit. Or just setup precommit hooks. Ps: don't ever exclude lock file from production code. If you don't wanna get headaches debugging production.

I honestly expect this from most developers. Reading the comments, the next level up is "rely on precommit". Once you realise how effective time pressure is at motivating --no-verify, you will go straight to GitHub actions that force PR checks, require reviewers and only allow certain people to bypass. The biggest one is forcing your PR to be up to date with mainline. I don't care if your branch passed tests and linting, I care if it still does after you've merged/rebased mainline.

Take that scenario and replace CI with a server runtime error that doesn't occur locally except under a very specific condition. Makes you feel insane after a while. Technology is complex is many varying ways, but learning from what we don't know is what empowers all of us to want to do better.

See more comments

To view or add a comment, sign in

Explore content categories