NPM (Node Package Manager) is the default package manager for Node and is written entirely in JavaScript. Developed by Isaac Z. Schlueter, it was initially released on January 12, 2010. NPM manages all the packages and modules for Node and consists of command line client npm.
NPM gets installed into the system with the installation of Node. The required packages and modules in the Node project are installed using NPM.
Prerequisites
We are going to discuss the following topics:
What is npm init?
To create a Node project, npm init is used in the folder in which the user wants to create a project. The command line will ask a number of questions like name of Project, license, scripts, description, author, keywords, version, main file etc. After npm creates the project, a package.json file will be created in the project folder as proof that the project has been initialized.
Steps to Setup the Project
Step 1: Create a NodeJS application by using following command
npm init
Step 2: After entering the command we need to answer some of the questions which are essential to initialize the project. We can press enter and set default answer or specify answer to the questions.
PS D:\GeeksforGeeks\Demo> npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help init` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
package name: (demo)
version: (1.0.0)
description: "Tutorial For npm init"
entry point: (index.js) app.js
test command:
git repository:
keywords: GeeksForGeeks, Nodejs
author: GeeksForGeeks
license: (ISC) MIT
About to write to D:\GeeksforGeeks\Demo\package.json:
{
"name": "demo",
"version": "1.0.0",
"description": "\"Tutorial For npm init\"",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"GeeksForGeeks",
"Nodejs"
],
"author": "GeeksForGeeks",
"license": "MIT"
}
Is this OK? (yes)
npm initpackage.json
//package.json
{
"name": "demo",
"version": "1.0.0",
"description": "\"Tutorial For npm init\"",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"GeeksForGeeks",
"Nodejs"
],
"author": "GeeksForGeeks",
"license": "MIT"
}
"npm init -y" Command
npm init -y command is used to set all the answers of the setup questions to default answers.
npm init -y
Similar Reads
CLI Commands in NPM NPM, short for Node Package Manager, is the default package manager for NodeJS. It is a command-line utility that allows you to install, manage, and share packages or modules of JavaScript code. These packages can range from small utility libraries to large frameworks, and they can be easily integra
4 min read
Important npm Commands Node Package Manager (npm) stands at the core of JavaScript development, serving as a robust package manager for handling dependencies, project initialization, and script execution. Understanding the essential npm commands is important for managing dependencies and automating tasks. In this article,
3 min read
What is Git Init? Git, a widely used version control system, allows developers to track changes in their code and collaborate efficiently. One of the first commands you will encounter when starting with Git is git init. This command is fundamental for creating a new Git repository, setting the stage for version contr
6 min read
Loading in Nuxt.js In this article, we are going to learn how loading works in Nuxt.js. Nuxt.js is a free and open-source web application framework based on Vue.js, Node.js, Webpack, and Babel.js. Nuxt is inspired by Next.js, which is a framework of a similar purpose, based on React.js. Introduction: Adding a loading
2 min read
What is spawn in Node JS ? Node JS is a cross-platform, open-source back-end JavaScript runtime environment that uses the V8 engine to execute JavaScript code outside of an internet browser. In this article, we will learn about the Spawn in NodeJs. PrerequisitesNodeJS fundamentalsAsynchronous ProgrammingChild ProcessesSpawn i
3 min read