2

[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.

Community
  • 1
  • 1
Dorothyy
  • 299
  • 1
  • 4
  • 13

2 Answers2

4

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
Vadim Baryshev
  • 25,689
  • 4
  • 56
  • 48
  • I was able to install npm. I already have the latest version of node.js. I installed node-gyp. When I tried to do: npm install sqlite3, I get this error: npm WARN install Refusing to install sqlite3 as a dependency of itself so I did the sudo apt -get install build-essential and then I tried again but still have the same error. Do you know why that may be? Does it matter where node-sqlite3 is in relation to the node.js folder? Right now, I have both folders in a folder called project-node. Does the sqlite3 folder need to be IN the node.js folder? Thank you so much. – Dorothyy Aug 09 '12 at 23:26
  • npm modules may be installed to any folders. It's not important. Try to install libsqlite3-dev. sudo apt-get install libsqlite3-dev. If it fails again post full npm error log here. – Vadim Baryshev Aug 09 '12 at 23:45
  • Oops, when I did sudo apt -get install build-essential I got this error: apt: invalid flag: -get and I get the same error when I did sudo apt -get install libsqlite3-dev. If i do apt-get without the space, I see: sudo: apt-get: command not found so I probably still don't have the build tools properly installed. Hm, ... – Dorothyy Aug 09 '12 at 23:50
  • apt-get (only without space) is a debian like (Debian, Ubuntu, Mint etc.) only OS package manager. If you are using other OS like Gentoo or MacOS, you need to use your OS package manager. – Vadim Baryshev Aug 09 '12 at 23:55
  • Is there a way to check if I already have the build tools installed? After I configure and make sqlite3, I have to use npm install to install it right? Is there any other way? Is it already usable? Do you know if this error: npm WARN install Refusing to install sqlite3 as a dependency of itself is a result of not havnig the build tools installed? Thank you, – Dorothyy Aug 10 '12 at 17:52
0

In case this did not work for some, here is what worked for me:

sudo apt install node-sqlite3

(I was trying to install sqlite3 for Ubuntu in order to work with nodejs and sqlite3 database (editor used is vscode). Even though I tried npm and sudo apt to install sqlite3, it kept giving an error "Module not found")

Snowcat
  • 470
  • 8
  • 16