Dorothyy
Dorothyy

Reputation: 299

Trouble with using a sqlite module for node.js

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

Upvotes: 2

Views: 6526

Answers (2)

Snowcat
Snowcat

Reputation: 526

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")

Upvotes: 0

Vadim Baryshev
Vadim Baryshev

Reputation: 26189

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

Upvotes: 4

Related Questions