nodejs, npm and sqlite3 [SOLVED]

So… today I decided to install the sqlite3 package in node… but then I got a non-nice error saying I didn’t have make installed. Yes, now I’m on Windows7.

I consider myself a rather eclectic guy when the subject is OSs. At home I have OSX, Windows7 and Ubuntu 12.10, and what I really like is the fact that I use the same code editor for all of them (buy Sublime, the best editor ever) and that I have all servers installed on all of them. Ok, for Windows I downloaded binaries, but they work. Just git clone a website and run it, simple like that.

But then, I got that error above. So I’ll document the steps to make it work here, and save myself (and hopefully others) some time with this notes.

preReqs

Npm is pretty awesome and brainless, but it’s good to take a look at the error log files if a requisite is missing. I had to download Python (and installed python’s win32 extensions) Already have VS2012 installed, so no need for C++ runtime, and the most important: downloaded GNUWin32 Utils. 400 and something packages, look into the folder for .bat files and read them. The first to be executed is download.bat.

After all is set, I’ve tried npm -g install sqlite3; it installed, but can’t use, don’t know why. Then when I installed with npm install sqlite3 (without -g) it created a node_modules folder and placed the module inside it. That did the trick. Working like a charm!

UPDATE

What was missing to make it work installing with -g was NODE_PATH in Environment Variables. Right-click My Computer > Properties > Advanced system settings > Environment Variables and add:

To test it, a little script, save as nodesqlite3.js:

And the result?

 

Also read...