Wednesday, February 7, 2018

Manage Packages with NPM - Node Package Manager

Node JS used to write JavaScript on the server side. To install specific packages to do a proper web development; npm is used. We require dependencies in package.json file. Then the node packages will be downloaded.

 To do we have to run npm init to initialize the program.

npm used to . . .
  • Adapt packages to your apps, or incorporate them as they are.
  • Download standalone tools you can use right away.
  • Run packages without downloading using npx.
  • Share code with any npm user, any where.
  • Restrict code to specific developers.
  • Form virtual teams (orgs).
  • Manage multiple versions of code and code dependencies.
  • Update applications easily when underlying code is updated.
  • Discover multiple ways to solve the same puzzle.
  • Find other developers who are working on similar problems.
Using npm init to Initialize a Project 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)

A Sample package.json file is

{
"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
}

package.json file is always structured in the JSON format.

No comments:

Post a Comment