Wether you are just getting started writing your first Node.js application or you are a front end developer looping to do some automation, NPM can help you manage your dependencies.  To play with the commands I am going to list in this article you just need to have node.js installed.  Luckily for us that is so super simple now days that I am just gonna grab a drink of coffee while you download and install it from the Node.js downloads page.

Every project starts with package.json  If for not other reason that you will write a description of why you even started it.  But luckily for us NPM will actually walk us through setting up our package.json by asking us some general questions.  From the root directory of our application running the init command of npm will get a guided setup.

npm init

name: (dunno)
version: (0.0.0)
entry point: (index.js)
test command:
git repository:
license: (BSD)
About to write to /Users/simeon/Desktop/dunno/package.json:

“name”: “dunno”,
“version”: “0.0.0”,
“description”: “ERROR: No README.md file found!”,
“main”: “index.js”,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1″
“repository”: “”,
“author”: “”,
“license”: “BSD”
Is this ok? (yes)

Note in the code above “dunno” happens to be the folder name that the the `npm init` command was run from.



Share This