Is it safe to delete ~/.npm-global?

Review first. Likely recoverable, but it costs you something to get back. Read before you move it.

What it is

A folder set as npm's global prefix: the packages installed with npm install -g, and the commands they add. npm's documentation says global installs go to lib/node_modules inside the prefix, and their commands are linked into its bin folder.

Made by
npm
If you remove it

The commands these packages added stop working until each package is installed again, which downloads it. Projects' own node_modules and npm's download cache are not stored here.

How it comes back
  • Put Back from Cleanup History while it is in the Trash.
  • Otherwise, list what is installed first with npm ls --global, then install each package again with npm install -g followed by its name.
  • By name alone npm installs the newest version; npm ls --global shows the versions you had.

The proof

Verified by
  • vendor documentation: npm, “folders” (https://docs.npmjs.com/cli/v10/configuring-npm/folders), “Global installs on Unix systems go to {prefix}/lib/node_modules.”; “npm ls” (https://docs.npmjs.com/cli/v10/commands/npm-ls); both read 9 Nov 2026.
  • Restore proved in a scratch prefix and cache (npm_config_prefix, npm_config_cache) on 9 Nov 2026 with npm 10.9.3: [email protected] installed globally and listed by npm ls --global; the prefix emptied, its command gone; npm install -g semver (exit 0) installed semver 7.8.6, the newest, and its command ran.
  • The real ~/.npm-global was not touched.
Checked on
macOS 26.6.2, npm 10.9.3, Node.js 22.18.0
Catalogue
Spaceific's rules.json 1.5.0, 10 Nov 2026. The whole file.

Related

Spaceific shows this rule for this folder in the app, checks it again at the moment you act, and moves only to the Trash, with Put Back. What Spaceific is.