This lesson is for PRO members.

Unlock this lesson NOW!
Already subscribed? sign in

npm init

1:29 Node.js lesson by

npm init provides an interactive step-by-step interface for creating a package.json

Get the Code Now
click to level up

egghead.io comment guidelines

Avatar
egghead.io

npm init provides an interactive step-by-step interface for creating a package.json

When you're going to work with nodejs or Browserify, the =easiest way to get started and prime your working directory is to use the npm init command. If we type "npm init," we're going to get a series of questions here.

It asks for the name. It's going to use the directory name by default.

It asks for a version. We usually start that off at zero.

Description. You can provide a description of your module here. I usually leave it blank when I'm getting started.

The entry point -- what will be the main file used for this module once it's done.

A test command to use for running unit tests.

Git repository. If I had set this up with a Git url already, it would prepopulate that and know where my Git repository is located.

You can provide keywords to indicate the sorts of things that your package does.

License ISC is basically a simplified version of MIT. If you want to change that to MIT or Apache or something, you can type in there.

Then you get a preview of what this file is going to look like. You can say yes, this is OK. It is going to then generate the package JSON that you have just instructed it to use.

You can see here that my author information is prepopulated because of some configuration settings I have in my environment.

There we go. We've got a basic starting point package JSON file to manage our dependencies.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?