LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

npm-edit

open an installed package's directory in the default editor

TLDR

Edit an installed package
$ npm edit [package]
copy
Edit a nested subpackage
$ npm edit [package]/[subpackage]
copy
Edit with a specific editor
$ EDITOR=[vim] npm edit [package]
copy
Configure the default editor persistently
$ npm config set editor [code]
copy

SYNOPSIS

npm edit pkg[/subpkg...]

DESCRIPTION

npm edit opens an installed package's directory in the default editor so it can be inspected or modified in place under `node_modules`. After the editor exits, npm rebuilds the package so any changes (for example to native addons) take effect.The editor is taken from the npm editor config, which defaults to the EDITOR or VISUAL environment variables (or `notepad.exe` on Windows, `vi` on Unix).

PARAMETERS

pkg

Name of the dependency to edit.
/subpkg
Optional nested package path, to drill into a transitive dependency under `node_modules`.
editor (config)
Editor used to open the package. Set with `npm config set editor <name>` or via EDITOR/VISUAL.

CAVEATS

Changes made to files in `nodemodules` are lost the next time npm reinstalls or updates the package. For persistent local modifications use **patch-package** or fork the package upstream. **npm edit** is not workspace-aware: in a workspace it operates on the root `nodemodules`.

HISTORY

npm edit has been part of npm since early releases, providing a quick way to read or hack on installed dependencies during debugging.

SEE ALSO

npm(1), npm-explore(1)

Copied to clipboard
Kai