Difference between revisions of "Npm"

From Logic Wiki
Jump to: navigation, search
Line 27: Line 27:
 
  npm i jshint --save-dev
 
  npm i jshint --save-dev
 
if a package is installed with --save-dev it will only be available in dev env. and not goes to production env.
 
if a package is installed with --save-dev it will only be available in dev env. and not goes to production env.
 +
== Uninstall a package ==
 +
npm un packagename
 +
== Upgrade npm ==
 +
sudo npm i -g npm
 +
== Publishing NPM Packages ==
 +
first create a npm user
 +
npm adduser
 +
login
 +
npm login
 +
enter username, password and email
 +
run
 +
npm publish
 +
=== Updating a published package ===
 +
Change the version number either manual (See [[Semantic Versioning]] or by npm command like
 +
npm version patch
 +
or
 +
npm version minor
 +
or
 +
npm version major
 +
then run
 +
npm publish to publish the updates in the package

Revision as of 13:27, 16 September 2018


to list all the packages and their dependencies with their version numbers

npm list

if we only want to list first level of packages

npm list --depth=0

To see the meta data of a package

npm view packageName

To see just the dependencies of a package

npm view packageName dependencies

Updating local packages

to list which updates are available

npm outdated 

to update minor and patch

npm update

to update majors first install this

sudo npm i -g npm-check-updates 

to see available updates run

npm-check-updates

to update package.json

npm-check-updates -u
ncu -u

install dependencies

npm i

Developer Dependencies

npm i jshint --save-dev

if a package is installed with --save-dev it will only be available in dev env. and not goes to production env.

Uninstall a package

npm un packagename

Upgrade npm

sudo npm i -g npm 

Publishing NPM Packages

first create a npm user

npm adduser 

login

npm login 

enter username, password and email run

npm publish

Updating a published package

Change the version number either manual (See Semantic Versioning or by npm command like

npm version patch 

or

npm version minor

or

npm version major

then run npm publish to publish the updates in the package