Skip to content

Instantly share code, notes, and snippets.

@kamal2222ahmed
Last active May 22, 2017 00:26
Show Gist options
  • Save kamal2222ahmed/15cd65d08e8cb21a6586ee48c497600e to your computer and use it in GitHub Desktop.
Save kamal2222ahmed/15cd65d08e8cb21a6586ee48c497600e to your computer and use it in GitHub Desktop.
### print to stdout all the versions of packages that are installed, as well as their dependencies, in a tree-structure.
$npm ls promzard
$npm -g list
test.js:
function npmls(cb) {
require('child_process').exec('npm ls --json', function(err, stdout, stderr) {
if (err) return cb(err)
cb(null, JSON.parse(stdout));
});
}
npmls(console.log);
run:
> node test.js
### When to use nodejs
is a command-line tool that can be run as a regular web server and lets one run JavaScript programs
utilizes the great V8 JavaScript engine
is very good when you need to do several things at the same time
is event-based so all the wonderful Ajax-like stuff can be done on the server side
lets us share code between the browser and the backend
lets us talk with MySQL
Some of the sources that I have come across are:
Diving into Node.js – Introduction and Installation (http://www.stoimen.com/blog/2010/11/16/diving-into-node-js-introduction-and-installation/)
Understanding NodeJS (http://debuggable.com/posts/understanding-node-js:4bd98440-45e4-4a9a-8ef7-0f7ecbdd56cb)
Node by Example (Archive.is) (http://blog.osbutler.com/categories/node-by-example/?page=3)
Let’s Make a Web App: NodePad (http://dailyjs.com/2010/11/01/node-tutorial/)
### get details on an npm module installed
npm list --depth=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment