InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Node.js tutorials

  • Install node.js on Ubuntu Linux
  • Install node.js on Mac
  • npm tutorial
  • Debug javascript using node and Chrome
  • Find source file location of a module
  • Find version of installed package
  • How to use pm2 to manage node.js application in production
  • NestJS Quick start tutorial on Mac
  • NextJS Quick start tutorial on Mac
  • Fix cannot find module error
 
  • Home
  • > Tutorials
  • > Web Development
  • > Node.js

NodeJS – npm beginner tutorial

By admin | Last updated on Sep 28, 2016

Npm (Node package manager) is used to install/uninstall and manage node packages. Here are some common commands when using npm on command line on Linux (Ubuntu) or Mac. Note that for Mac sudo can be skipped if node package has been installed as user.

Get info of a package

This will also tell us what is latest version available for a package:

$ npm info phantomjs
npm http GET https://registry.npmjs.org/phantomjs
npm http 200 https://registry.npmjs.org/phantomjs

{ name: 'phantomjs',
  description: 'Headless WebKit with JS API',
  'dist-tags': { latest: '1.9.19', alpha: '2.0.0-alpha' },
...

Install a package locally

This is default option (no -g flag)

$ npm install jslint

Install a package globally

$ sudo npm install -g jslint

Install a specific version package globally

$ sudo npm install -g jslint@0.10.3

Upgrade already installed package globally

$ sudo npm upgrade -g jslint
// or
$ sudo npm update -g jslint

List currently installed packages globally

Use npm ls -g (npm ls aliases: list, la, ll). This will list packages with dependency tree.

$ npm ls -g
/usr/local/lib
└─┬ jslint@0.9.5
  ├── exit@0.1.2
  ├─┬ glob@4.5.3
  │ ├─┬ inflight@1.0.4
  │ │ └── wrappy@1.0.1
  │ ├── inherits@2.0.1
  │ ├─┬ minimatch@2.0.10
  │ │ └─┬ brace-expansion@1.1.2
  │ │   ├── balanced-match@0.3.0
  │ │   └── concat-map@0.0.1
  │ └─┬ once@1.3.3
  │   └── wrappy@1.0.1
  ├─┬ nopt@3.0.6
  │ └── abbrev@1.0.7
  └─┬ readable-stream@1.0.33
    ├── core-util-is@1.0.2
    ├── inherits@2.0.1
    ├── isarray@0.0.1
    └── string_decoder@0.10.31

List only top level packages in dependency tree

$ npm ls -g --depth 0

List a specific package

$ npm ls -g --depth 0 | grep casperjs
├── casperjs@1.1.0-beta5

Uninstall a package globally

$ sudo npm uninstall -g jslint

Suggested posts:

  1. How to install and monitor memcache for php on Ubuntu Linux
  2. How to install node (node.js) on Mac
  3. How to install phantomjs on Mac
  4. bower – installation and quick start guide
  5. How to use CasperJS to automate website testing
  6. Mysql 5.7 root password after installation
  7. HTML import
  8. CSS flex-basis
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Linux, Linux/Unix Command Line, Mac, Node.js, Tutorials, Ubuntu Linux
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress