npm init

Share this video with your friends

Social Share Links

Send Tweet

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

Instructor: [00:00] 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.

[00:13] It asks for the name. It's going to use the directory name by default.

[00:16] It asks for a version. We usually start that off at zero.

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

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

[00:32] A test command to use for running unit tests.

[00:36] 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.

[00:47] You can provide keywords to indicate the sorts of things that your package does.

[00:52] 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.

[01:01] 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.

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

[01:23] There we go. We've got a basic starting point package JSON file to manage our dependencies.