Previous Topic , In this tutorial, we are going to learn Creating package.json file inside Visual Studio Code and creating Cypress Project.
What is package.json file? and Whats its use for?
As it name referrers, it a json file which resides in the root of the project and stores metadata
of the current project, its key role is managing all the dependencies and successfully
running the script in our local machine. We will be taking the example for 2 dependencies in our package.json file to understand more in details with the help of NPM commands. But going further we need to understand NPM is depth.
What is NPM? Creating package.json file
Steps to Create Package.json file through VC Terminal
1) Go to the terminal create a folder with preferred name ex( CypressProject) and move to the folder. Below are the commands:
//this command will create folder with name CypressProject mkdir CypressProject //this command with move to CypressProject Folder cd CypressProject
2) Now create npm project with below command
// Command npm -i init
3) Now the terminal would ask you multiple pre-requisite (ex: package name, version etc) . Click to Enter for every pre-requisite or keep it on default data, till the json file gets generate on terminal (refer the screenshot)
4) At last type “Yes” for question Is this OK?
5) Now setup cypress dependency on using the below npm command and hit enter.
//This command will install cypress dependency npm install cypress --save-dev
6) As we hit command npm start download , unzip and finish Cypress dependency.
7) Once the Installation is completed click to open folder and select the folder we created above (CypressProject) from directory
8) Now we are completed with creation of VC project. Click to package.json file where you can see all the dependency mentioned on .json file as per below screenshot