npm comes bundled with Node.js, and the name covers three things: the command-line tool, the public registry at npmjs.com with millions of packages, and the company that runs it, which is part of GitHub.
The key files
package.json: project name, required packages and scripts.package-lock.json: the exact version of every package and sub-dependency.node_modules/: where packages are actually installed.
{
"scripts": {
"start": "node server.js",
"build": "vite build"
},
"dependencies": { "express": "^4.21.0" },
"devDependencies": { "vite": "^6.0.0" }
}
The ^ allows updates within the same major version (4.x) but never jumps to 5. devDependencies are build and development tools the app doesn’t need at runtime.
Essential commands
| Command | What it does |
|---|---|
npm install |
Installs packages and updates the lockfile if needed |
npm install axios |
Adds a new package to the project |
npm ci |
Clean install that matches the lockfile exactly: right for servers and CI/CD |
npm ci --omit=dev |
Skips dev dependencies in production |
npm run build |
Runs the build script from package.json |
npm audit |
Checks packages for known vulnerabilities |
Common problems
EACCESonnpm install -g: global installs need write access to system folders. Install the package locally or usenpx: see npm EACCES.ERESOLVE: conflicting peer dependencies; fixes on the ERESOLVE page.- Copying
node_modulesfrom Windows to a Linux server: some packages contain platform-specific binaries, so reinstall on the server. - Deleting the lockfile to “fix” things: it may work for now, but you’ll get new, untested versions.
On ArabyHost
On AI/Developer plans, Setup Node.js App creates a separate environment for each app, with a Run NPM Install button that installs from package.json. The CloudLinux selector keeps node_modules inside that environment and links it into your app folder with a symlink, so delete any uploaded node_modules folder before installing. Over SSH, activate the environment with the command shown on the app’s page, then run npm ci or npm run build. There’s no root access, so skip -g. Full steps in the Node.js deployment guide.
FAQ
What's the difference between npm and npx?
npm installs packages and manages the project; npx runs a command from a package without installing it globally, such as npx create-next-app. Both come with Node.js.
Should I delete package-lock.json?
No. It makes sure the server installs exactly the versions you tested. Commit it to Git and use npm ci on the server.
Why is node_modules so big?
It holds every package plus all of their dependencies. Don't commit it or upload it over FTP; recreate it on the server with an install command.