Skip to main content

Use of the package.json file?

Package.json is a file found in all npm packages and is normally found in the project root.

It contains various metadata about the project.

This file provides information to npm so that it can identify the project and handle its dependencies.

 It can also contain other metadata, such as a project description, the project’s version.

A Node.js project’s package.json file is usually found in the root directory.

This example of package.json file used for writing code using cypress

{“devDependencies”: {“cypress”: “9.5.2”}}

What are devDependencies in the package.json file?

Dependencies are specified with a simple hash of package name to version range. The version range is a string that has one or more space-separated descriptions. Dependencies can also be identified with a tarball or gitUrl.

devDependencies: Packages that are only needed for local development and testing.

What is tarball?

The tarball is a compressed file format. You need to unpack it before running the npm command.

What is "dependencies" in package.json file?

"dependencies": Packages required by your application in production.

How to Install Cypress on Windows using npm

Users can install cypress on windows by giving the single command “npm install cypress”. But to run this command it is important that npm is installed on the machine.

How to check if npm is installed on the machine or not?

Navigate to command prompt and type command npm -v

If windows show any version then npm is installed on a machine. If no version is specified then follow the article to install npm on windows.

Once NPM is available on windows then type the command “npm install cypress” and press enter.

After successful installation type command “npx cypress –version” and press enter to check if cypress is installed or not.

C:\Users\Admin>npx cypress –version
Cypress package version: 9.1.1
Cypress binary version: 9.1.1
Electron version: 15.2.0
Bundled Node version:
16.5.0

After successful installation of cypress system will create 1 directory node_modules and 1 package.json file.

Where node_module contain multiple folders like below

node_module directory listing
Node Module Cypress Installation Folder

package.json file will look like

package.json file
package.json dependencies

To uninstall cypress from windows using the command line follow this article Uninstall Cypress from Windows command line.

What is NPM, Node JS, and how to install it on Windows?

NPM Stands for Node Package Manager, which is an application and repository for developing and sharing JavaScript code.

What are Node and Node JS?

Node and Node JS are similar, Node is just a shorter way to describe Node JS. Node or Node JS refers to the javascript runtime environment that allows you to write server-side code.

To handle multiple concurrent clients node JS uses “Single Threaded Event Loop”.

How to install Node JS on Windows?

  1. Open Command prompt in Windows (Type cmd in Search bar and press enter)
  2. Type “node -v” and press enter to check if node is already installed or not.
  3. If node is not installed then system will give below message

C:\Users\Admin>node -v
‘node’ is not recognized as an internal or external command,
operable program or batch file.

4. Download Node JS from authorized website i.e https://nodejs.org/en/download/

Node JS Installer Screen

5. Installing node-v16.13.1-x64 version using node-v16.13.1-x64.msi installer. but at the time of installation please check latest version.

Double click on node-v16.13.1-x64.msi and follow the instructions by clicking on Next button.

After successful installation system will display below screen.

Node JS Installation Message

Click on Finish and Navigate to Command Promot again (Make sure to open new command prompt. If already exists then close it and reopen it.)

On Command prompt type command node -v to check if node is installed or not.

C:\Users\Admin>node -v
v16.13.1

Check if NPM is installed or not type this command “npm -v”

C:\Users\Admin>npm -v
8.1.2

The Node.js installer includes the NPM package manager.