Question

Using npm link to update dependencies during development is kind of a pain.

Does NPM have the equivalent of Composer's "--prefer-source" option to install dependencies as a version control repo?

Était-ce utile?

La solution

No

Git repos are never cloned directly into your application. They always follow this process:

  1. npm does a bare clone of the repo into $TMPDIR
  2. npm clones that clone into a directory in your npm cache, and then checks out the treeish that the branch requested mapped to.
  3. npm produces an installable package tarball from that checkout that is then placed into your npm cache.
  4. that cached tarball is installed into your application.

If you want to be working directly from the Git checkout of your project, with all its submodules intact, your best bet is probably to npm link for the project with the submodules, and then npm link it into the package consuming it. It's more unwieldy than using Git URLs in your package.json, but it will give you the control you need about how files are laid out.

Source: https://github.com/npm/npm/issues/6700#issuecomment-71302066

Feature request for npm at Github for this feature: https://github.com/npm/npm/issues/7375

Autres conseils

Another solution is npmgitdev. This is a wrapper which lets you work directly with git repos inside node_modules.

you can add your dependencies as links to git like this:

"foo" : "git+https://git.server.host/bar/baz.git#master"

see the docs for more information

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top