Most JavaScript developers know how to use NPM:
npm install express npm install npm run dev npm publish
Enter fullscreen mode
Exit fullscreen mode
But knowing these commands is very different from understanding what NPM is actually doing .
When you run:
npm install
Enter fullscreen mode
Exit fullscreen mode
NPM is not simply downloading some files.
It is solving a dependency graph, resolving versions, communicating with a registry, validating package metadata, building an installation tree, generating or updating a lockfile, running lifecycle scripts, and storing packages in a local cache.
And when you run:
npm publish
Enter fullscreen mode
Exit fullscreen mode
you are not simply uploading a folder.
You are creating a versioned package artifact that can become a dependency of thousands of other applications.
Understanding these internals changes how you think about:
package.json
package-lock.json
semantic versioning
dependency conflicts
node_modules
npm scripts
workspaces
package…