Wednesday, 30 November 2016

npm commands


npm init 

Create Package.js file in that particular folder


Refer the above page

{
  "name": "index.js",
  "version": "1.0.0",
  "description": "index",
  "main": "main.js",
  "dependencies": {
    "lodash": "^4.17.2"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}


npm ls

Display all the packages in that particular folder
npm install (Package Name)

 Install the package
npm uninstall (Package Name)
Unistall the Package

node main.js
Compile the file and starts the running the code inside the file
Node –v
Version details of node
npm install [package_name] --save

By default, NPM simply installs a package under node_modules. When you're trying to install dependencies for your app/module, you would need to first install them, and then add them (along with the appropriate version number) to the dependencies section of your package.json.
The --save option instructs NPM to include the package inside of the dependencies section of your package.json automatically, thus saving you an additional step.
In addition, there are the complementary options --save-dev and --save-optional which save the package under devDependencies and optionalDependencies, respectively. This is useful when installing development-only packages, like grunt or your testing library.
It's documented in the documentation for npm install

enter image description here