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

后端 未结 6 970
爱一瞬间的悲伤
爱一瞬间的悲伤 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:30

    As of npm 1.0 (which is now what you get by default if you follow the steps in the README file), "bundle" is no longer a segregated thing -- it's just "how it works".

    So:

    1. Put a package.json file in the root of your project
    2. List your deps in that file

      { "name" : "my-project"
      , "version" : "1.0.0"
      , "dependencies" : { "express" : "1.0.0" } }
      
    3. npm install Since you're calling this with no args, and not in global mode, it'll just install all your deps locally.

    4. require("express") and be happy.

提交回复
热议问题