Skip to main content

Getting Started with NPM

Tags

NPM Logo

Looking for new ways to level up in the web development world I am always looking to do things more efficiently.  Along my quest for efficiency I recently ran into Gulp, a building tool that uses node js under the hood and is powered by npm, Node Package Manager.   npm is a great tool to manage node packages and dependencies, kind of like rpm and yum are to Red Hat, or pacman is to Arch.   A lot of popular tools out there right now, like LESS, GruntGulp, and CoffeeScript have node packages available for download.  You could probably develop all aspects of an entire project with tools that were download from a node repository. 

 

 

Permissions

For Windows

  1. Install Node JS.  nodejs
    1. Hit the install button.  The website will recognize your user agent and start downloading the correct distribution.  At the time of this post, the latest version is 0.10.28.
    2. Start the installer and run through the installation as usual.<
  2. Navigate out to C:\Program Files, you should see the nodejs folder here now.
    1. Right click on the Nodejs folder and select properties.
    2. Select the security tab.
    3. Select edit on the security pane.
    4. In the box that pops up, select the users group and give that group full control.  This will allow you to work with npm to install packages into the nodejs directory without issues.
    5. Hit OK and OK again to close the properties.
  3. Steps 4 and 5 are optional if npm does not work after install nodejs.  If npm is available, skip to step 5 ## and test npm out. 
  4. Install Git.
    1. Navigate out here to get the latest download of Git.  At the time of this post the latest version is: 1.9.3.
    2. Run through the installer that Git gives you and make sure for Windows to select the option that describes: “Run Git from the Windows Command Prompt.
  5. Clone npm with Git!
    1. Start up the command prompt and run these commands:
# navigate to the base of your C: directory
> cd /
 
# make git aware of the signing certificate
> git config --system http.sslcaininfo /bin/curl-ca-bundle.crt
 
# clone the npm repo from github
> git clone – recursive git://github.com/isaacs/npm.git
 
# change directories to npm
> cd npm 
 
#install command line usage globally for npm
> node cli.js install npm –gf

5. OK, Node and npm are installed, happy downloading! Try it out by creating a blank folder and installing an npm package.

 

# create a blank folder and jump into the new folder
> mkdir test
> cd test
 
# using npm install less in this folder
> npm install less
 
# you should now see the node_modules folder in this directory, success!

For Mac:

  1. Install Node JS. http://nodejs.org/
    1. Hit the install button.  The website will recognize your user agent and start downloading the correct distribution.  At the time of this post, the latest version is 0.10.28.
    2. That is it, npm comes packaged in with NodeJS on Mac and should run right away.

In case npm is not working, use git to clone the npm repo, pull it down and install it globally.

If there are any questions please let me know.

Member for

3 years 9 months
Matt Eaton

Long time mobile team lead with a love for network engineering, security, IoT, oss, writing, wireless, and mobile.  Avid runner and determined health nut living in the greater Chicagoland area.