What is npm?

npm Open-source World's largest  package manager for the JavaScript programming language it can be either nodejs.angularJs etc.. any JS library/framework.

Basically npm has two part 

  • Largest software library
  • Package Manager and Installer

As a updated version of npm it is free to use the packages and also for organizations use npm to manage private development as well.

You can also contribute share your packages publicly, there is no cost but if you want to make it private for organizations one has to upgrade the plan offered by npm Orgs

npm registry contains million of code packages.

Command Line Client-Installing npm

npm includes CLI (Command Line Client) by which you can manage your packages like install ,version check, update etc.Now if you install nodejs if npm cli automatically get with it.To download nodejs https://nodejs.org

In order to install and mange packages in cli you have to run npm init command you were asked several questions and once you run this command it will create package.json file in your directory 

 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 json` 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: (testing) npm test
Sorry, name can only contain URL-friendly characters.
package name: (testing) npm-test
version: (1.0.0)
description: npm test desc
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to D:\BHANU\D Drive\Bhanu\desktop\AdminLTE-2.4.10\AdminLTE-2.4.10\pages\testing\package.json:

{
  "name": "npm-test",
  "version": "1.0.0",
  "description": "npm test desc",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}


Is this OK? (yes)

Managing Dependencies

npm can manage dependencies.

npm can (in one command line) install all the dependencies of a project.

Dependencies are also defined in package.json.

{
  "name": "node-admin",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "nodemon ./app.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.19.0",
    "chalk": "^3.0.0",
    "ejs": "^3.0.1",
    "express": "^4.17.1",
    "mysql2": "^2.0.1",
    "sequelize": "^5.21.2"
  },
  "devDependencies": {
    "nodemon": "^2.0.1",
    "sequelize-cli": "^5.5.1"
  }
}

 

Leave a reply

your email address will not be published. required fields are marked *

Name *
Email *
Website