Managing third-party libraries (not node) with nodejs?

I use the package.jsonfile to define nodejs requirements along with npm updateand of course it works fine.

How can I manage (update the easy way) other third-party libraries using node? For instance:

https://github.com/documentcloud/backbone.git
https://github.com/twitter/bootstrap.git

In the folder vendor.

+5
source share
3 answers

Summary: I think you want to use http://twitter.github.com/bower/

Details: There are two ways to understand your question:

  • How to manage / update the code not npm?
  • How to manage / update client side javascript assets?

, , .

, , npm -style package.json. , . .

. , . , : BPM, Jam Ender. , , : -

, - ( , require-js, , /minification ..) .

Bower Twitter. / vendor . . .

+5

git:

http://git-scm.com/book/en/Git-Tools-Submodules

git GitHub

[ 1] :

git submodule add git://github.com/documentcloud/backbone.git vendors/backbone
git submodule add git://github.com/twitter/bootstrap.git vendors/bootstrap

: http://skyl.org/log/post/skyl/2009/11/nested-git-repositories-with-github-using-submodule-in-three-minutes/

+2

nodejs, , Composer , . , Composer PHP, , -npm nodejs. , package.json, . nodejs, .

:

  • json , package.json.
  • ,
  • , nodejs

:

  • php cli
  • Extra step for updating dependencies
  • Additional json file for dependencies

Here's how to do it (you should be able to run php from cli):

1. Download Composer (directly to the root nodejs project folder)

curl -s https://getcomposer.org/composer.phar > composer.phar

2. Create a composer.json file (in the root of the project)

{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "twitter/bootstrap",
                "version": "2.0.0",
                "dist": {
                    "url": "https://github.com/twitter/bootstrap/zipball/master",
                    "type": "zip"
                },
                "source": {
                    "url": "https://github.com/twitter/bootstrap.git",
                    "type": "git",
                    "reference": "master"
                }
            }
        }
    ],
    "require": {
        "twitter/bootstrap": "2.0.0"
    }
}

3. Run the Composer Update

php composer.phar update 

This will download the package to the folder vendorat your request:

├── vendor
│   ├── ...
│   ├── composer
│   │   └── installed.json
│   └── twitter
│       └── bootstrap
│           ├── LICENSE
│           ├── Makefile
│           ├── README.md
│           ├── docs
│           │   ├── assets
│           │   └── ...
│           ├── img
│           │   ├── glyphicons-halflings-white.png
│           │   └── glyphicons-halflings.png
│           ├── js
│           │   ├── bootstrap-affix.js
│           │   └── ...
│           ├── less
│           │   ├── accordion.less
│           │   └── ...
│           └── ...
+1
source

All Articles