Using npm to install or update required packages just like bundler for rubygems

后端 未结 6 924
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-30 03:57

I love Bundler, it\'s great at dependency management. I love npm, installing node packages is easy! I have a nodejs app and would love to be able to specify my apps de

6条回答
  •  庸人自扰
    2021-01-30 04:25

    You should read these two articles from Isaacs(author npm) blog. I think they are really good, and I believe tell you how to achieve your goal:

    1. http://blog.izs.me/post/1675072029/10-cool-things-you-probably-didnt-realize-npm-could-do
    2. http://foohack.com/2010/08/intro-to-npm/

    I believe link #1(point #11) explains this:

    11: Bundle all your dependencies into the package itself

    When you use the npm bundle command, npm will put all your dependencies into the node_modules folder in your package. But it doesn’t stop there.

    If you want to depend on something that’s not on the registry, you can do that. Just do this:

    npm bundle install http://github.com/whoever/whatever/tarball/master This will install the contents of that tarball into the bundle, and then you can list it as a dependency, and it won’t try to install it when your package gets installed.

    This also is handy if you have your own fork of something, and would prefer not to change the name.

    In fact, you can run almost any npm command at the bundle. To see what’s inside, you can do npm bundle ls. To remove something, do npm bundle rm thing. And, of course, you can install multiple versions and activate the one you want.

提交回复
热议问题