Create a sample project with NodeJS and NPM

This is a broad overview and introduction to NodeJS. It will cover quite a few things that you can do with NodeJS without going too deeply into them. But it should give you a good idea of what you can do with NodeJS.

You must have NodeJS (and NPM) installed. You can install NodeJS by going to this page and choosing the 64-bit Windows Installer (.msi). When you install NodeJS, NPM will also get installed. NodeJS is the runtime program that can execute your JavaScript code (up until now, all of our JavaScript code has been executed by a browser). And NPM is a tool that you can use to install JavaScript packages (NPM = Node Package Manager).

Setting up the project

Create a folder named node-sample-project. This will be our project folder, and you'll see me make references to the 'project folder' in my instructions below.

Open a terminal and cd into the project folder that you just created.

Initialize a Node project by running this command:

npm init -y

This will create a file named package.json which is required for all npm projects. We'll talk more about this important file, but for the moment just know that it is a file that has information about your project.

Now, create a folder named samples inside the project folder (the node-sample-project folder). We'll put most of our sample programs in this folder.

Later we'll be creating some custom modules, so add a modules folder to the project folder.

Add a README.md file to the project folder.

Add a heading to the readme file that says Node Sample Project.

Add a .gitignore file to the project folder and put this in it:

node_modules

We'll be talking more about the node_modules folder later, but for now just note that you do NOT want Git to track the files in it. So, by creating a .gitignore file nad adding 'node_modules' to it, Git will ignore the folder completely

Initialize a git repository by running this command:

git init

Add and commit the files we've created by running these commands:

git add .
git commit -m "First commit"

Before moving on, make sure to publish the repository to GitHub.