Mainly Devel Notes

Twitter, GitHub, StackOverflow: @ovrmrw (short hand of "overmorrow" that means the day after tomorrow)

Solution for npm install Red Errors on Windows

Node.js, Windows, npm, Development Environment

(This post is English version of Windowsでnpm installの赤いエラーに悩まされているアナタへ)

I know preparing Node.js Dev Environment on Windows is really painful... until today.
They says "Install VC++ something" "Needed Windows SDK something" "If 32bit then hogehoge If 64bit then foobar"... and so on. Even after trying anything I can what I thought, npm install shows me many many Red Errors. Just what I got is unuseful old and very big trash --Visual Studio 2010-- on my HDD.
Oh, what a terrible history.

BUT, Today, I introduce you a perfect(probably) solution about preparing Node.js Dev Environment on your Windows!

Although npm install usually just downloads files from Npm, some libraries need to BUILD after downloading. If your environment is not correct, that causes Red Errors. I know you've nearly thrown your keyboard and mouse.

Ok, introducing steps with Microsoft's guideline, here we go.

First, Install Node.js

Node.js
I recommend you to install v5.1.0 Stable for Windows.(As of 2015-11-27)
Because that contains Npm3 which deploys under node_modules folder as flat. So you can avoid causing The Problem of Too long folder tree To delete.

Install Git

Git
I recommend you to choose "Use Git from the Windows Command Prompt" when installing, that will help you.

Install VC++ something and Python, Execute npm config set

Configuring your Windows development environment
The page above is very helpful, you had better to read it.
For busy people I've excerpted a profitable way from the guideline.

  1. Install VC++ Build Tools Technical Preview
    • You can't install it if you've already installed Visual Studio 2015. If you so, ok, uninstall Visual Studio for now.
    • If you choose custom install, don't check "Windows 8.1 SDK" off that is needed.
    • It needs .NET Framework 4.5.1 to install.
  2. Install Python 2.7, and add it to your PATH, npm config set python python2.7
    • Download Python 2.7.10 and install it. Don't forget to check "Add python.exe to Path" on.
    • After installation, execute npm config set python python2.7 on Command Prompt.
    • Confirm your setting worked by npm config list.
  3. Launch cmd, npm config set msvs_version 2015 --global (this is instead of npm install [package name] --msvs_version=2015 every time.)
    • Execute npm config set msvs_version 2015 --global on Command Prompt.
    • Confirm your setting worked by npm config list.
  4. SO MUCH npm install

Install node-gyp as global

npm install node-gyp -g

Maybe this is needed.

Try install some libraries which need to build

Microsoft's guideline says "Here are a few packages you can try installing to see if your environment is set up properly."
Libraries below need to build, ok try it.

  • bson
  • bufferutil
  • kerberos
  • node-sass
  • sqlite3
  • phantomjs
  • utf-8-validate

Make a folder then execute npm install.

npm install bson bufferutil kerberos node-sass sqlite3 phantomjs utf-8-validate

No Red Errors? That's perfect!!


Thanks for your reading.

Remove all ads