Ran into trouble installing NPM packages today. Running npm install in my working directory where a package.json exists and includes project dependencies resulted in only a handful of packages getting installed in node_modules/ and errors when I tried to install the rest one by one.

Ultimately, I needed to update XCode on my computer and install v0.12 of Node instead of the latest released version. Before I realized that was the case, I learned how to manually install NPM packages without using npm install <somepackage>. I thought it was a useful piece of info to share. Hope it's helpful to you.

Installing NPM Packages Manually

Note: This assumes you have Node installed and npm.

  1. Go to the package's repo on Github.com
  2. Copy the HTTPS clone URL to your clipboard
  3. cd /usr/local/lib/node_modules (where NPM puts packages you install globally).
  4. git clone <clone URL>
  5. cd into the package directory
  6. run npm install

Example installing nodemon:
1. Go to https://github.com/remy/nodemon
2. Copy HTTPS clone URL
3. cd /usr/local/lib/node_modules
4. git clone git@github.com:remy/nodemon.git
5. cd nodemon
6. npm install

Tags: