Trouble with using a sqlite module for node.js

Problem

[I tried to include more links to make my questions more clear but stackoverflow wouldn't let me because I do not have 10 reputation points.]

I have node.js and now I want to choose a sqlite module for it and my choices are: orlandov/node-sqlite, developmentseed/node-sqlite3, and grumdrig/node-sqlite. I eliminated grumdrig because only synchronous access is supported.

When I tried to explore developmentseed by following their directions, I encounter this problem:

./configure

./configure: line 3: node-gyp: command not found

So I tried to use npm install (also suggested) and encounter this problem:

npm install sqlite3
-bash: npm: command not found

When I tried to get npm with

curl http://npmjs.org/install.sh | sh

I encounter this problem (even with sudo and changing owner/permission):

curl http://npmjs.org/install.sh | sh

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0    85    0    85    0     0    175      0 --:--:-- --:--:-- --:--:--     0

**sh: line 1: syntax error near unexpected token `newline'**

sh: line 1: `<html>Moved: <a href="https://npmjs.org/install.sh">https://npmjs.org/install.sh</a>'

I looked at stackoverflow's: Node.js : NPM Install Fails and Nodejs + Node-Sqlite3 Installation Problem and many other links but haven't found a solution.

I am also having trouble configuring node-sqlite by orlandov.

I just wanted to play around with node-sqlite (by orlandov) and node-sqlite3 (by developmentseed) so I can choose the better one but am stuck here.

Oh, I also looked into node-gyp at github -- /TooTallNate/node-gyp/ but it seems to also need npm.

I'd appreciate any suggestions on how to get these to build and/or which to use between developmentseed and orlandov's.

Problem courtesy of: Dorothyy

Solution

To install npm directly use this command:

curl -k https://npmjs.org/install.sh | sudo sh

If you use Ubuntu you can install lastest versions of node.js and npm from PPA. Note: you need to remove your current nodejs first.

sudo apt-get install python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs nodejs-dev npm

Install node-gyp:

sudo npm install -g node-gyp

Now you ready to install sqlite3 from npm.

npm install sqlite3

Note: build tools need to be installed before sqlite3 setup.

For ubuntu:

sudo apt-get install build-essential
Solution courtesy of: Vadim Baryshev

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.