npm-edit
opens an installed package's directory in the default editor
TLDR
Edit installed package
$ npm edit [package]
Edit with specific editor$ EDITOR=vim npm edit [package]
SYNOPSIS
npm edit pkg
DESCRIPTION
npm edit opens an installed package's directory in the default editor. This allows direct modification of package code for debugging or local patches.
The editor is determined by the EDITOR environment variable.
PARAMETERS
pkg
Package name to edit.
EXAMPLE
$ # Edit lodash package
npm edit lodash
# Opens in $EDITOR at node_modules/lodash
# Use specific editor
EDITOR=code npm edit express
npm edit lodash
# Opens in $EDITOR at node_modules/lodash
# Use specific editor
EDITOR=code npm edit express
USE CASES
$ - Debug package issues
- Apply local patches
- Inspect package internals
- Test modifications
- Apply local patches
- Inspect package internals
- Test modifications
ALTERNATIVES
$ # Use patch-package for persistent changes
npx patch-package package-name
# Or fork the package
git clone https://github.com/user/package
npx patch-package package-name
# Or fork the package
git clone https://github.com/user/package
CAVEATS
Changes lost on npm install/update. Use patch-package for persistent patches. Editing in node_modules is generally discouraged.
HISTORY
npm edit has been part of npm since early versions, providing quick access to edit installed dependencies.
SEE ALSO
npm(1), npm-explore(1), patch-package(1)
