npm Tutorial - 2 - npm init and package.js - npm Tutorial For Beginners
www.VictorDozal.com
What is npm? In 2 minutes - npm tutorial for beginners
• What is npm? In 2 minutes - npm tutor...
----------------------------------
Hellooooo there, beautiful, amazing and gorgeous people.
In this tutorial we will be going over initializing an npm project and the purpose of a package.json file
To clarify, this tutorial should work for windows, mac, and linux users.
Let’s get started!
To begin, I have created a simple project with two files: index.html and scripts.js
Open a terminal, and go to the directory where your project lives.
Once you are there, type “npm init”.
This will ask you a bunch of questions. You can leave the defaults by pressing “enter” on each question. The questions asked will be the project name, version, description, the JavaScript file where everything will start (aka the entry point), a test command (we will not cover testing in this tutorial, so ignore it), the git repository url for the project, keywords relating to the project, the author, and license type.
Whew! That was a long list! As you can see, after going through those steps, it now asks if it’s okay to create a package.json and shows us the content.
Say yes, and you should be all set initializing the npm project. That was easy.
Open the project directory and you should now see the “package.json” file that was created.
Let’s click on it to see the contents. Nice!
Let me quickly explain what a package.json file is.
The package.json is a file that contains information about your application. Most importantly, this file will contain the list of packages or dependencies that your project needs to run. In the package.json file we can also write something called “scripts”, which are commands that we can run from the terminal in order to make our lives easier in several ways. We will go over dependencies and scripts on later tutorials.
Now let’s delete the package.json file becase I want to show you a much quicker way to get a project initialized.
Open your terminal once again and type “npm init --yes”. This does the same thing as “npm init”, except this time npm knows that you want to initialize a project with all the defaults.
As you can see, it now tells us that the package.json file was created. Let’s go check it out!
Go back to the project’s directory and open the package.json file.
Cool! Everything works as expected.
If you have any questions leave a comment for me and I’ll do my very best to help you out.
As always, please don't forget to support me by subscribing, liking the video, leaving a comment, and sharing the video with your friends.
See you next time!