Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The best way to start a project in Node is to create a package.jason file. In this video we'll use the npm command to generate this file for us. First let's create a folder for this project. I'm going to create it on the desktop and name it airline. Now go to terminal. Type in cd and space, and now drag the folder into terminal to get the path. Now type return. Now I'm going to use a tool called npm. Npm is distributed with node and it helps with module installation, among other things Right now we're going to use npm to help us generate a package.json file.
To do that type npm and it. After you press enter, it'll step you through the creation of the file. The first thing it prompts you for is the name, and if you don't specify a name, it'll just use the name of the folder where the package.json file is going to be. In this case it's airline, and that's fine with me. So I'm going to hit return. Next it's going to ask you for a version. In this case, I'm just going to accept the default because I don't care. Next, it's going to ask for description of the project. Let's type in a small description.
After the description, it's going to prompt for an entry point. Every project that you create in Node is going to have an entry point. And in this case I'm just going to accept the default of index.js. Now it's going to prompt for a test command. Later on, we can set this up to automatically run unit tests. But at the moment, we're just going to leave this blank. After test, it allows us to supply the path to a git repository. This is useful if you're distributing your project to someone else, but in this case we're just building it for ourself.
So leave git repository blank. Next there are keywords. Again, this is if you're distributing the project elsewhere, so leave it blank. Now it's prompting for an author. In this case, I'm going to type in my name, and then I'm going to supply my email address in angle brackets. After author, it's going to prompt for a license. You can add any license you like here. And, in this case, I'm just going to accept the default. After answering all of the questions, it's going to show you a preview of the package.json file. If everything is okay, you can just type return.
Now, when we list the contents of the folder, there's a package.json file. I'm going to open it up in SublimeText. The package.json file identifies a project, who authored it, and which file is the entry point. This file will also keep track of the modules this project depends on. In the next video, we'll use this package.json file to keep track of the community-provided modules as we're installing them.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 104791 Viewers
56 Video lessons · 116664 Viewers
71 Video lessons · 85859 Viewers
131 Video lessons · 41075 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.