NPM-PREFIX(1)
π
npm-prefix β yeah bestie, it's the NPM-PREFIX(1) page β¨
Okay so real talk, this one is short but it matters, and I'm gonna make sure you get every single crumb of it. Let's go π«Ά
β¨ NAME β¨
npm-prefix β nope that's not a typo, it literally just displays the prefix. That's the whole job. Iconic, honestly. π
πΈ Synopsis πΈ
npm prefix
β οΈ heads up bestie: this command is unaware of workspaces. Like, it does not know them, does not see them, does not care. No cap. π
π¦ Description π¦
So what does it actually do? It prints the local prefix to standard output. And what even is the local prefix? It's the closest parent directory that contains either a package.json file or a node_modules directory β unless you also pass -g, in which case everything changes (dramatically, as we're about to see).
If -g is specified, you get the value of the global prefix instead. Wanna know more about that? Go run npm help config, it's all there. β¨
π Example π
Here's the vibe in action, look at her go:
npm prefix
/usr/local/projects/foo
npm prefix -g
/usr/local
See? Local one gave you that nice deep project path, and the -g one gave you the top-level global situation. Slay. π
π Configuration π
β global
- Default:
false - Type:
Boolean
Turning this on makes npm operate in "global" mode", which means packages get installed into the prefix folder instead of the current working directory. Curious about all the behavioral differences? npm help folders has you covered, bestie. π§
So when global is on:
- π¦ packages are installed into the
{prefix}/lib/node_modulesfolder, instead of the current working directory - π bin files are linked to
{prefix}/bin - π man pages are linked to
{prefix}/share/man
π See Also π
npm help rootnpm help foldersnpm help confignpm help npmrc
And that's the whole page, you ate that fr fr π Go forth and prefix with confidence. π
Signed, sealed, delivered: NPM@12.2.1 β dated October 2026 β and yes, it's still NPM-PREFIX(1) at the bottom, exactly where it belongs. πβ¨
π¦ where this page comes from
- arch rolling: npm 12.2.1-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms