Lesson 02
Generating the Project with NPM
Summary
Node.js Project Setup for nvk Bookstore
Welcome back! In this lesson, we will generate a Node.js project called nvk bookstore. This session assumes you have Node.js installed.
Steps to Create the Project
-
Open Terminal:
- Navigate to your desired directory and create a new folder:
mkdir nvk_bookstore cd nvk_bookstore
- Navigate to your desired directory and create a new folder:
-
Initialize the Project:
- Run the following command to create a new Node.js project:
npm init
- You will be prompted to answer a few questions for your
package.json
:- Package name: nvk_bookstore (default)
- Version: 1 (default)
- Description: (Optional, can skip)
- Entry point: app.js
- Test command: (Optional, can skip)
- Repository: (Optional, can skip)
- Keywords: (Optional, can skip)
- Author: (Your name or username)
- License: MIT (or choose your own)
- Run the following command to create a new Node.js project:
-
Install Express:
- Now, install Express by running:
npm install express
- Note: In older versions of Node.js, you might need to add
--save
to the install command.
- Now, install Express by running:
-
Check the
package.json
:- After the installation, the
package.json
file will include Express as a dependency.
- After the installation, the
Conclusion
Now that we have set up our project and installed Express version 4.16.3, we will start writing our first file in the next lesson. See you then!
Video Transcript
Welcome back everyone. So let's start and generate a project. What we're going to do
we're going to go to the terminal. Okay so this course already assumes that you
have Node.js installed. Okay so to get started let's first generate a Node.js
project. I am going to make a directory here and call it nvk bookstore. So I'm
going to cd to nvk bookstore. This is where our project is going to be. You can
call it whatever you want. Okay just how I'm going to call this project. Now
there's nothing here yet. Let's do an npm init to create a project. But before I do
that I would like to point out that this video is being recorded using Node version
8.12.0. Okay so npm init will ask a few questions before I can create the
file package.json that's going to serve a project. So I'm just going to choose the
default package name and the case bookstore. Version I'm going to leave at
one. Description you can add whatever you want there. I'm just going to skip it.
For the entry point I'm just going to say app.js. That's a file we're going to
write with our server. Task command that we don't have it yet and we won't care
for this course. Get prepository if you have one. If we to add there. I don't care about
keyword author put your name. I can put mine username. Doesn't really matter.
License you can choose your own license. Let's use MIT for me. Is this okay? Yes. So
you see now if I open the text editor I use item by the way and go back there.
Here is the package.json that was created by the npm init command. Okay not much there.
Now let's finally get to install express. Let's get back to the terminal. Okay let me clear this.
We're going to do npm install express. Notice because in the previous versions of node npm it
used to be that you needed to say dash dash save if you want to add this dependency to the package
json. So it already does automatically for me but if you're using a version of node that does not
do that. Node the older version. You should put dash dash save there. In any case we now have if I go
back to the text editor to package.json we now have express here. We're using express version 4.16.3
in this video. Okay just so you know. Now that's all good. Great and now we have to start writing
a first file. So I'm going to leave that to the next lesson. I'll see you then. Okay.
No comments yet (loading...)
No comments yet (loading...)
Did you like the lesson? 😆👍
Consider a donation to support our work: