npm install for adding node modules to a project is a cinch, but every once in a while you might come across a module that needs to actually be built for your system. While moving this blog from an Azure Website account to an Azure Virtual Machine, I ran into just this issue with Ghost's dependency on
sqlite3 as its storage mechanism (you can use MySQL, but the default Azure Website install of Ghost uses SQLite).
Copying the files directly over was unsuccessful, installing Ghost from scratch was unsuccessful, and installing just the
sqlite3 node module was also unsuccessful.
Behind the scenes, the npm dependency chain uses node-gyp for native builds. This native build on a Windows machine requires python 2.7, as well as a Visual Studio installation. The node-gyp add-on requires the Visual Studio C++ tooling (Express for Windows Desktop apps will work), and potentially the Windows 7 SDK, if the VS installation doesn't take care of it. Once these requirements are met, node-gyp should be able to build the SQLite node module. If errors are still occurring--specifically a type mismatch on the C++ tooling--it might be necessary to target a specific Visual Studio version with the following command:
npm install sqlite3 --build-from-source --msvs_version=2013