npm unlink: Usage & Common Errors
Remove a symlink created by npm link.
npm unlink removes a link created by npm link - either the per-project symlink or the global one - so the project goes back to using the registry-installed dependency.
What it does
In a consuming project, npm unlink <name> removes the symlink from node_modules; you then run npm install to restore the real package. Run in the library directory with no args, it removes the global link.
Common usage
Terminal
npm unlink my-lib && npm install # restore the real dependency
# in the library, remove the global link:
npm unlinkCommon gotcha: package missing after unlink
After npm unlink the project throws "Cannot find module" because unlink only removed the symlink - it did not install the real package. Always follow npm unlink with npm install (or npm ci) to put the registry version back.
Terminal
npm unlink my-lib
npm install # reinstall the real dependencyRelated guides
npm link: Usage & Common Errorsnpm link symlinks a local package into another project for development. Usage in two steps, the global prefix…
Node.js "Cannot find module" After Install - Fix Missing DependencyFix Node.js "Error: Cannot find module" in CI - a require that resolves to nothing because the package is mis…
npm install: Usage, Options & Common CI ErrorsWhat npm install does, the flags you actually use, and the install failures that break CI builds - ERESOLVE,…