npm link, without linking devDependencies

In [email protected] or lower

When you run npm link in other_module then you will get both dependencies and devDependencies symlinked.

The --production flag doesn't change anything, still creates a symlink to the whole directory

In [email protected]

They fixed it!

If you remove node_modules and then do npm link --only=production, it runs an install before symlinking, and therefore devDependencies folder are indeed excluded.


A workaround I use is npm pack then point to the packed file in the example


This is currently not possible with npm link. The problem is, if you install only prod dependencies in that dependency, you're able to link it, but you're not able to develop on that dependency anymore (since missing devDependencies). And vice-versa: If you install devDependencies, you can't link anymore.

The solution: A package called npm-local-development at https://github.com/marcj/npm-local-development

It basically does the same thing as npm link, but works around the devDependency limitation by setting up a file watcher and syncs file changes automatically in the background, excluding all devDependencies/peerDependencies.

  1. You install npm-local-development: npm i -g npm-local-development
  2. You create file called .links.json in your root package.
  3. You write every package name with its local relative folder path into it like so

    { "@shared/core": "../../my-library-repo/packages/core" }

  4. Open a console and run npm-local-development in that root package. Let it run in the background.

Disclaimer: I'm the author of this free open-source project.