Npm unbound devDependencies

It seems that when I launched npm link , it will install the project all over the world, and it seems to install devDependencies with it.

Is there a way to run an npm link without devDependencies, possibly with the --only=production flag?

+7
source share
3 answers

In npm@4.x or below

When you run npm link in other_module , you will get symbolic links and devDependencies.

The --production flag --production not change anything, it still creates a symbolic link to the entire directory

In npm@5.1.0

They fixed it!

If you remove node_modules and then run npm link --only=production , it starts the installation before symlinking, so the devDependencies folder is really excluded.

+8
source

This is currently not possible via npm link . The problem is that if you only install prod dependencies in this dependency, you can link it, but you can no longer develop this dependency (since devDependencies is missing). And vice versa: if you install devDependencies, you can no longer link.

Solution: a package called npm-local-development at https://github.com/marcj/npm-local-development

It basically does the same as npm link , but bypasses the devDependency limitation by setting up a file viewer and automatically synchronizes file changes in the background, excluding all devDependencies / peerDependencies.

  1. You install npm-local-development: npm i -g npm-local-development
  2. You create a file called .links.json in your root package.
  3. You write each package name with its local relative path to the folder, like so

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

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

Disclaimer: I am the author of this free open source project.

+2
source

I just wanted to add another possible alternative to npm link, which I found and found more suitable for developing a local interface:

https://medium.com/@tnrich_29519/a-better-alternative-to-npm-yarn-link-for-the-front-end-667f03d497a6

0
source

Source: https://habr.com/ru/post/1269004/


All Articles