Paris.js #33, January 29th 2013, @Dj3bbZ
Source: http://stuartmcghee.deviantart.com/art/Captain-Obvious-339839060
Contrary to the belief of many, "npm" is not in fact an abbreviation for "Node Package Manager". It is a recursive bacronymic abbreviation for "npm is not an acronym".Node.js FAQ
npm is for packages, not Node.js modules.
A package is a folder containing a program described by a package.json fileNode.js FAQ
It could work, if only package.json wasn't required...
Bower does this already.
napa is a small npm plugin (<100 LOC !) for installing repos without a package.json with npm
{
"scripts": {
"install": "napa"
},
"napa": {
"foo": "username/repo",
"bar": "git@example.com:user/repo",
"woo": "username/repo#v1.2.3",
"bam": "username/bar#some-branch",
"baz": "username/baz#347259472813400c7a982690acaa516292a8be40",
"qoo": "https://example.com/downloads/release.tar.gz"
}
}
npm can run arbitrary scripts
npm run <myscript>
{
"scripts": {
"test": "mocha --reporter spec --timeout 1000",
"build-js": "uglifyjs src/app.js > build/app.js",
"build-css": "cat css/reset/*.css css/app/*.css > build/app.css",
"build": "npm run build-js && npm run build-css",
"pbuild": "npm run build-js & npm run build-css"
}
}
Bonus : local packages with a "bin" property are available.
No more global modules \o/
Scripts can be used like makefiles. Browserify can build your code, and is super flexible.
Write code like Node.js modules, Browserify packages it for you
{
"scripts": {
"build-js": "browserify src/app.js > build/app.js"
}
}
Works with scripts that exposes global variables, Node.js modules, AMD modules, ES6 modules (!). More info
If you need Grunt, Bower, you already have npm.
That's (generally) all you need.
Remember, Less is more
.
Slides are published here : djebbz.github.io/npm-paris-js