npm init

$ npm init
# Scaffolds a package.json file with details based on prompted inputs

Explanation

As NodeSource explains: “The npm init command is a step-by-step tool to scaffold out your project. It will prompt you for input for a few aspects of the project in the following order:

  • The project’s name,
  • The project’s initial version,
  • The project’s description,
  • The project’s entry point (meaning the project’s main file),
  • The project’s test command (to trigger testing with something like Standard)
  • The project’s git repository (where the project source can be found)
  • The project’s keywords (basically, tags related to the project)
  • The project’s license (this defaults to ISC – most open-source Node.js projects are MIT)”

Result

A sample output of a package.json file, as shown on NodeSource:

“Here’s an example of how these fields would look in a package.json file:

{
"name": "metaverse", // The name of your project
"version": "0.92.12", // The version of your project
"description": "The Metaverse virtual reality. The final outcome of all virtual worlds, augmented reality, and the Internet.", // The description of your project
"main": "index.js"
"license": "MIT" // The license of your project
}

Back To TIL