Saturday, November 24, 2018

How to create a package.json file in project

Creating a default package.json file

To create a default package.json using information extracted from the current directory, use the npm init command with the --yes or -y flag

You can create package.json from the command prompt or directly from Visual Studio Code.

1. Open Visual Studio Code
2. Click on Terminal menu
3. Click 'New Terminal'
4. You will see that Terminal is open at the bottom-most screen of Visual Studio Code
5. Run below command

6. Default package.json file created will look something like

Updating package.json file

You can update the 'description' and 'author' as per your need manually or you can run below commands.

Setting config options for the init command


Saving npm dependencies in package.json file

1. Run below commands one by one so that it gets saved in package.json file and later it will be easy for us to install all dependencies by giving one commend.

2. If you run command npm install then it will install all the dependency in one go and it will save your time in typing individual command when you are deploying code on another system.
Finally you can update the package.json file as below

Done!!!

No comments:

Post a Comment