Skip to content

๐Ÿ“„ A step-by-step guide to creating and setting up a Node.js project

License

Notifications You must be signed in to change notification settings

samirzaee/nodejs-project-setup-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Node.js Project Setup Guide

๐Ÿ“„ A step-by-step guide to creating and setting up a Node.js project.

Step One: Starting the directory(repository)

There are two ways to start the directory:

  1. Starting the repository on an online Git service (like GitHub,...):
    In this way (for example, on GitHub), we will have these at once:

    • An initialized git repo with a name
    • A README.md with the repo's short description
    • The initial commit with the above changes
    • (optional) A LICENSE file (Note that the license file could have no file extension or one of .txt, md or, rst. The .md and the no-extension are the most common options.) (For licenses also this repo could be useful.)
    • A .gitignore file (On GitHub, for example, you'll get a big .gitignore file)

    Note: The .gitignore you're given by the platform (.e.g GitHub) probably is a very big one that contains ignores for any cases. You don't need all of them. So you need to either delete anything that you don't need or create your .gitignore file manually and fill it out through the process of building the project as you will need it. The basic .gitignore file is like this:

    .gitignore

    /node_modules/
    

    Don't forget to commit changes.

    And finally, clone the repo (if you didn't yet) and run npm init command, go through steps and, then commit the changes.

  2. Starting the directory locally:
    Steps needed in this way are:

    1. Create the directory with a proper name

    2. Run git init command to initialize the repo

    3. Commit changes as the initial commit

    4. Add the README.md with a very short description (then commit it)

    5. Add the basic .gitignore file like below:

      .gitignore

      /node_modules/
      

      And commit changes.

    6. Initialize npm with npm init command and go through steps, and then commit the changes.
      Note: Here, the difference with the other way is that you need to manually add the remote repository address to the package.json later. (for example, after your first push)

      You need to add these to your package.json file:

      "repository": {
      "type": "git",
      "url": "git+https://github.com/samirzaee/nodejs-project-setup-guide.git"
      },
      "bugs": {
      "url": "https://github.com/samirzaee/nodejs-project-setup-guide/issues"
      },
      "homepage": "https://github.com/samirzaee/nodejs-project-setup-guide#readme"

      Change URLs based on your remote repo.

    7. As you probably saw and did in the steps of initializing npm, you have the license field of your package.json filled with what you specified. But you don't have a license file in your directory. You can add it using the steps explained in for Github remote repositories. If your remote repository is not on GitHub, you can use the GitHub steps to get the license text and then copy and paste it to your manually created license file. The license file is like one of these:

      • LICENSE (preferred - more common)
      • LICENSE.md (preferred - more common)
      • LICENSE.txt
      • LICENSE.rst

      And must be in the root of the directory(/repository). The first two are the most commonly used options.
      For licenses also, this repo could be useful.

About

๐Ÿ“„ A step-by-step guide to creating and setting up a Node.js project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published