Join egghead, unlock knowledge.

Want more egghead? It's 45% off for a limited time only!

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock All Content for 45% Off

Already subscribed? Sign In

Save 45% for a limited time.

Get access to all courses and lessons on egghead today.

Autoplay

    npm init

    Ben ClinkinbeardBen Clinkinbeard

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

    javascriptJavaScript
    nodeNode.js
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    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.

    Discuss

    Discuss