npm
npm is the JavaScript package manager that comes with Node.js: a terminal tool that downloads and installs libraries and programs from a public registry. The npx command runs such a program without installing it permanently. Claude Code can be installed through npm with npm install -g @anthropic-ai/claude-code, provided you have Node.js 22 or later.
A “store” of ready-made code pieces for JavaScript, used from the terminal. npx starts such a piece without installing it; pnpm is an alternative to npm.
How it shows up in Claude Code
npm is one of the official install routes, alongside the recommended native installer. The documentation says the npm package installs the same native program as the standard installer. To update it, you run npm install -g @anthropic-ai/claude-code@latest; the documentation advises against npm update -g, which may not move you to the newest version.
In projects, npm shows up all the time: Claude runs npm install to fetch the pieces a website needs, npm test to check the code, or npx to run a tool just once, like the Vercel program in the first lab. When Claude wants to run one of these commands, it asks your permission first, so you can see exactly what it's about to install.
Example
Installing through npm, in a terminal:
npm install -g @anthropic-ai/claude-code
claude --version
The first command installs Claude Code for the whole computer (-g stands for “global”). The second prints the version, a sign it worked.
Common mistakes
- Using
sudo npm install -g. The documentation says plainly not to, because it can lead to permission problems and security risks. - Choosing npm without having Node.js. If you don't know what Node.js is, the native installer is simpler.
- Updating with
npm update -gand staying on an old version. - Deleting the
package-lock.jsonfile. It records the exact installed versions, so the project works the same everywhere.
Related terms and where you learn it
npm needs Node.js and installs dependencies, recorded in a lockfile. You run it from the terminal.
It comes up in the lesson “How to install it, step by step”, in module 00 · Installation and first steps.
How it appears in the course
It works via npm too, but only if you already have Node.js, version 22 or newer. If you don’t know what that is, skip it.
How to install it, step by step · Module 00, Installation and first steps · free
You tell Claude directly, for example: “add to CLAUDE.md the rule: always use pnpm, not npm”. Claude writes it into the file.
How do you get started quickly? · Module 02, CLAUDE.md: your project’s memory
How you start the project on your computer (pnpm dev), how you run the tests (all of them or just one) and which checks must pass before you save your changes.
A ready-made example · Module 02, CLAUDE.md: your project’s memory
Learn Claude Code from zero, in plain English
12 modules with 1–2 minute lessons, which you can also do on your phone. The first two modules are free.