NPM Dependency Management: package.json vs package-lock.json | NodeFlux.eu Docs
Avoid production deployment crashes by managing NPM dependency trees cleanly with lockfiles.
Steps
- Always generate package-lock.json locally before deploying by running npm install.
- Commit package-lock.json along with package.json in your project repository or upload payload.
- Never upload node_modules folder over SFTP; let NodeFlux install dependencies on the target container.
- Use npm ci instead of npm install in server startup scripts for reproducible, faster dependency builds.
- Audit dependencies locally using npm audit to identify and patch security vulnerabilities.
Notes
- npm ci strictly adheres to package-lock.json and will fail if lockfile is out of sync with package.json.
- Skipping node_modules upload speeds up SFTP transfer times by up to 95%.
Related NodeFlux pages
- Setting up WebSocket and Socket.io Real-Time Servers — Host real-time bidirectionally connected apps using Socket.io or native ws module on assigned service ports.
- Managing Node.js Process Lifecycles with PM2 — Use PM2 process manager configuration files to handle auto-restarts, environment injection, and log management.
- Structuring Express and Fastify Web APIs for Production — Build lightweight, production-ready HTTP REST APIs with proper port binding and error handling.