21

I have the most recent version of node.js built with no problems. I am trying to use a sqlite module for node.js.

For node-sqlite3 by developmentseed, I followed the directions:

git clone git://github.com/developmentseed/node-sqlite3.git
cd node-sqlite3
./configure
make

I installed npm with: curl -k https://npmjs.org/install.sh | sudo sh

and installed node-gyp with npm: sudo npm install -g node-gyp

After node-sqlite3 configure-d and make-d okay, I tried to install with npm, I get this:

npm install sqlite3
npm WARN install Refusing to install sqlite3 as a dependency of itself

When I researched this error, I found this question: npm install sqlite3 error so I tried:

 node-waf clean || true; node-waf configure build

but got this error:

/usr/local/bin/../lib/node/wafadmin/Utils.py:136: DeprecationWarning: the md5 module is deprecated; use hashlib instead
from md5 import md5
Waf: Please run waf from a directory containing a file named "wscript" or run distclean
/usr/local/bin/../lib/node/wafadmin/Utils.py:136: DeprecationWarning: the md5 module is deprecated; use hashlib instead
from md5 import md5
arg[0] directory does not contain a wscript file

When I tried to build orlandov/node-sqlite, I got it from git and then tried:

node-waf configure build

but I get this error:

/usr/local/bin/../lib/node/wafadmin/Utils.py:136: DeprecationWarning: the md5 module is
deprecated; use hashlib instead
from md5 import md5
Checking for program g++ or c++          : /usr/bin/g++
Checking for program cpp                 : /usr/bin/cpp
Checking for program ar                  : /nnmc/cvsbin/ar
Checking for program ranlib              : /usr/bin/ranlib
Checking for g++                         : ok
Checking for program gcc or cc           : cc
Checking for gcc                         : ok
Checking for node path                   : not found
Checking for node prefix                 : ok /usr/local
'configure' finished successfully (0.070s)
Waf: Entering directory `/U1/dorothyy/project_node/node-sqlite/build'
/U1/dorothyy/project_node/node-sqlite/deps/mpool-2.1.0
make: Nothing to be done for `all'.
Waf: Leaving directory `/U1/dorothyy/project_node/node-sqlite/build'
Traceback (most recent call last):
File "/usr/local/bin/node-waf", line 16, in <module>
Scripting.prepare(t, os.getcwd(), VERSION, wafdir)
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 145, in prepare
prepare_impl(t, cwd, ver, wafdir)
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 135, in prepare_impl
main()
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 188, in main
fun(ctx)
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 386, in build
return build_impl(bld)
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 405, in build_impl
bld.compile()
File "/usr/local/bin/../lib/node/wafadmin/Build.py", line 255, in compile
self.flush()
File "/usr/local/bin/../lib/node/wafadmin/Build.py", line 717, in flush
tg.post()
File "/usr/local/bin/../lib/node/wafadmin/TaskGen.py", line 219, in post
self.apply()
File "/usr/local/bin/../lib/node/wafadmin/TaskGen.py", line 206, in apply
v()
File "/usr/local/bin/../lib/node/wafadmin/TaskGen.py", line 464, in apply_core
node = find_resource(filename)
File "/usr/local/bin/../lib/node/wafadmin/Node.py", line 183, in find_resource
st = Utils.h_file(path)
AttributeError: 'module' object has no attribute 'h_file'

I cannot use grumdrig/node-sqlite because it does not support asynchronous access.

Thank you for any suggestions.

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

6 Answers6

52

I got this error when my app had the same name as one of the packages I was (npm) installing. I was just doing some practise and had not thought I needed a unique name for the project...

Just change the name in your package.json to something else and it should work.

Simon H
  • 20,332
  • 14
  • 71
  • 128
17

You don't need to execute

npm install sqlite3

in node-sqlite3 folder. By executing this command you trying to install sqlite3 as dependency of sqlite3 (you already have it).

There are two ways to install sqlite3:

First:

In your project folder execute

npm install sqlite3

You dont need to clone git project before it. Don't need to configure and make it manually. Just execute this command in your project folder where you want to use sqlite3 module. You should see folder node_modules/sqlite3 in your project folder after npm finish. Now you can use it in your project by require:

var sqlite3 = require('sqlite3');

Second:

Use this way only if npm install fails. (Paranormal).

  1. Go to your project folder.
  2. Create folder node_modules if not exists.
  3. Execute:

    git clone git://github.com/developmentseed/node-sqlite3.git
    cd node-sqlite3
    ./configure
    make
    
  4. Ok. Now sqlite3 half-ready to use. We need to install dependencies. Execute:

    npm install
    

    Attention: npm install without other parameters. This command use package.json in your sqlite3 folder to install dependencies.

After npm finish you can use sqlite3 module in your project.

Vadim Baryshev
  • 25,689
  • 4
  • 56
  • 48
  • I have a folder project_node and inside there is node-sqlite3 and node-v0.8.5 (latest version of node.js). Does node-sqlite3 need to go in node-v0.8.5? If I try npm install sqlite3 in node_project or in node-v0.8.5, I get this error: -bash: npm: command not found Can you please clarify what you mean by my project folder? Thank you. – Dorothyy Aug 13 '12 at 21:00
  • In you question you wrote that you already install npm and use it for install node-gyp. Now you say that npm not found. Very strange. What operating system do you use? – Vadim Baryshev Aug 13 '12 at 21:04
  • Yes, it is very strange, even when I go into /node-sqlite3 where I had used it before and try to use npm, it says command not found. I am using Putty on Windows. – Dorothyy Aug 13 '12 at 21:07
  • I mean the server operating system where you are connecting through putty. – Vadim Baryshev Aug 13 '12 at 21:11
  • I used curl -k https://npmjs.org/install.sh | sudo sh in project_node folder and then did npm install sqlite3 and received a list of errors including: /usr/bin/env: node: Permission denied. It is too many characters to post here. – Dorothyy Aug 13 '12 at 21:11
  • Red Hat Enterprise Linux Server release 5.4 – Dorothyy Aug 13 '12 at 21:19
  • 2
    Try to reinstall node.js and npm by this instructions: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager . Find 'RHEL/CentOS/Scientific Linux 5 and 6' section on the page. It's oficial joyent docs. – Vadim Baryshev Aug 13 '12 at 21:28
  • This project needs to be compiled on a 32-bit system so when I configured the source code from nodejs.org, I used: ./configure --prefix /usr/local --dest-cpu ia32 . Could I do this with the RHEL/CentOS/Scientific Linux 5 and 6 directions? When I followed them, I encountered : several missing dependency errors that can be skipped by using --skip-broken. This is when I realized it is compiling 64-bit but I need 32-bit. – Dorothyy Aug 13 '12 at 22:46
  • Here is the news about npm: https://github.com/isaacs/npm/blob/master/README.md . Now it comes with node.js. Try this: 1). uninstall your current node.js by executing 'make uninstall' in node.js src folder you downloaded. 2). download last node.js source: wget http://nodejs.org/dist/v0.8.6/node-v0.8.6.tar.gz . 3). Untar by tar -zxvf ./node-v0.8.6.tar.gz . 4). cd node-v0.8.6 5). ./configure --dest-cpu ia32 NOTE: do not use --prefix option. 6). make 7). sudo make install . 8). try node -v 9). try npm -v – Vadim Baryshev Aug 14 '12 at 01:05
  • I uninstalled my previous node.js, I followed your steps and everything seemed to be working great. I then got sqlite3 from developmentseed's github and put it inside the node-v0.8.6 folder, ./configured (had to npm install node-gyp), and then built it which was fine. Then I went back to the node-v0.8.6 folder and tried npm install sqlite3 but I got a long list of errors starting with: gyp ERR! configure error and ending with npm ERR! not ok code 0 – Dorothyy Aug 14 '12 at 17:49
  • You don't need to download configure and make modules manually if node.js and npm installed normally. And don't need to do it in node-v0.8.6 folder. It's just sources. After successful installation of node.js and npm you need only: sudo npm install -g node-gyp and npm install sqlite3 in your project folder. – Vadim Baryshev Aug 14 '12 at 18:40
  • I successfully install node.js and npm and sqlite3 is no longer in the folder with node.js but when I try npm install sqlite3, I get these: gyp ERR! configure error and ... npm ERR! Failed at the sqlite3@2.1.5 install script. npm ERR! This is most likely a problem with the sqlite3 package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get their info via: npm ERR! npm owner ls sqlite3 – Dorothyy Aug 14 '12 at 19:21
  • Sorry, no more ideas. I successfully install sqlite3 module without any problems on several machines (but x64). Carefully read all error logs. Maybe it will help you to find a bug. – Vadim Baryshev Aug 14 '12 at 19:43
  • Thank you for all of your help. I was finally able to build it. Because I was using root to wget, and clone, and install and all that jazz, the permissions everywhere didn't match up, I changed them all to my user and was able to successfully build. I think that was the reason at least. (Even though I wasn't even able to build with root.) – Dorothyy Aug 17 '12 at 22:30
7

Just leave the directory of the module you want to install and try to install it again. This worked for me. So:

cd ..
npm install sqlite3
marcinsdance
  • 634
  • 7
  • 17
2

Check if your project folder name is same as the module you are trying to install,

If you try to install express inside a project folder name express, you will get this error.

Rename your Project Folder, Your project Folder name should be unique compared to the npm module names

Also change the package.json file entry

 "name": "xxxxx",
  "version": "1.0.0",
Community
  • 1
  • 1
Ignatius Andrew
  • 8,012
  • 3
  • 54
  • 54
2

This Error occurs when your package name is same as package you are going to install.
Go to package.json check name property init

{
name:"xxxx",
...
}

May be it will help.

Dr.jacky
  • 3,341
  • 6
  • 53
  • 91
Naveen Gupta
  • 306
  • 3
  • 11
0

I guess in the package.json file, the name of the project is sqlite3. So when you try to install that it rejects due to some reasons as mentioned that it becomes dependency. So try to change the name of project in package.json and give a try. For further reference checkout :http://thisdavej.com/node-newbie-error-npm-refusing-to-install-package-as-a-dependency-of-itself/