Although this may not be the nodejs way, and some purists may complain, Composer will do what you want. Even though Composer is used with PHP projects there is no reason why it cannot be used to manage 3rd party non-npm repos for nodejs projects too. Obviously it is preferable for the 3rd party library to include a package.json but thats not aways going to happen. I tried this on my current nodejs app and it worked perfectly for me.
Pros:
- One json file specifies custom external dependancies that do not have package.json files
- Customize where packages are stored in the project folder
- Works with private repos and repos not originally intended for use with nodejs
Cons:
- Requires php cli
- An extra step for updating dependancies
- An extra json file for dependancies
Here how to do it (You need to be able to run php from the cli):
1. Download Composer (directly into your 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 into the vendor
folder as you requested:
├── 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
│ │ └── ...
│ └── ...