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_modules folder, 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 root
  • npm help folders
  • npm help config
  • npm 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