10

i am not sure why, but i am having issues while installing any of the packages using npm. i tried to install sqlite3 and it gave error as follows:

    naphstor@ubuntu:~$ sudo npm install sqlite3
    [sudo] password for naphstor: 

    > [email protected] preinstall /home/naphstor/node_modules/sqlite3
    > node-waf clean || true; node-waf configure build

    Nothing to clean (project not configured)
    Setting srcdir to                        : /home/naphstor/node_modules/sqlite3 
    Setting blddir to                        : /home/naphstor/node_modules/sqlite3/build 
    Checking for program g++ or c++          : /usr/bin/g++ 
    Checking for program cpp                 : /usr/bin/cpp 
    Checking for program ar                  : /usr/bin/ar 
    Checking for program ranlib              : /usr/bin/ranlib 
    Checking for g++                         : ok  
    Checking for node path                   : not found 
    Checking for node prefix                 : ok /usr/local 
    Checking for sqlite3                     : not found 
    Checking for library sqlite3             : not found 
    /home/naphstor/node_modules/sqlite3/wscript:29: error: the configuration failed (see             '/home/naphstor/node_modules/sqlite3/build/config.log')                                            
    npm ERR! error installing [email protected] Error: [email protected] preinstall: `node-waf        clean || true; node-waf configure build`
    npm ERR! error installing [email protected] `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
    npm ERR! error installing [email protected]     at ChildProcess.<anonymous>  (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
    npm ERR! error installing [email protected]     at ChildProcess.emit (events.js:70:17)
    npm ERR! error installing [email protected]     at maybeExit (child_process.js:359:16)
    npm ERR! error installing [email protected]     at Process.onexit               (child_process.js:395:5)
    npm ERR! [email protected] preinstall: `node-waf clean || true; node-waf configure  build`
    npm ERR! `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
    npm ERR! 
    npm ERR! Failed at the [email protected] preinstall 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-waf clean || true; node-waf configure build
    npm ERR! You can get their info via:
    npm ERR!     npm owner ls sqlite3
    npm ERR! There is likely additional logging output above.
    npm ERR! 
    npm ERR! System Linux 3.0.0-12-generic
    npm ERR! command "node" "/usr/local/bin/npm" "install" "sqlite3"
    npm ERR! cwd /home/naphstor
    npm ERR! node -v v0.5.11-pre
    npm ERR! npm -v 1.0.106
    npm ERR! code ELIFECYCLE
    npm ERR! 
    npm ERR! Additional logging details can be found in:
    npm ERR!     /home/naphstor/npm-debug.log
    npm not ok
    naphstor@ubuntu:~$ 

any idea why is it like that. it shows same kind of error in installing any of the other packages.

I can do it with a workaround like "git clone git://github.com/developmentseed/node-sqlite3.git" but was wondering why npm gives error while installing any of these packages.

1

7 Answers 7

9

This can be fixed by forcing SQLite3 to compile. npm install sqlite3 --build-from-source

Make sure you have these following dependencies installed

  1. python-software-properties
  2. python
  3. g++
  4. make
  5. build-essential

or run sudo npm install -g node-gyp

You will find more informations there (SQlite3 section): http://support.ghost.org/troubleshooting/

Sign up to request clarification or add additional context in comments.

Comments

3

Node version can be the issue, so for node 10.x and later, just install [email protected], as in specify the version

Comments

0

Try updating npm. I just tested it with the latest version, and it worked.

Alternatively, try one of these packages:

https://github.com/grumdrig/node-sqlite
https://github.com/orlandov/node-sqlite

Comments

0

I faced this problem as well then i removed node js what i downloaded and installed from ubuntu repos and downloaded source code from official node js site and compiled after it again tried to install sqlite without problem it worked i advise u to update your node and npm version as well

Comments

0

I try to install sqlite with npm on raspberrypi 3 all the night and finally found an alternative way to achieve that, I've just ran:

$ sudo apt install libsqlite3-dev

$ npm install sqlite3 --build-from-source --sqlite=/usr

Hope this help.

Comments

0

I encountered the same problem and fixed it by following these steps.

  1. Install the latest Python version via brew (v3.13.0), previously I was using v3.11.7 installed via anaconda - brew install python
  2. Update your bash or zsh profile to use the python installed via brew (not anaconda). In my case, I updated ~/.zshrc file and commented out the script that initializes anaconda.
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
# __conda_setup="$('/opt/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
# if [ $? -eq 0 ]; then
#     eval "$__conda_setup"
# else
#     if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
#         . "/opt/anaconda3/etc/profile.d/conda.sh"
#     else
#         export PATH="/opt/anaconda3/bin:$PATH"
#     fi
# fi
# unset __conda_setup
# <<< conda initialize <<<
  1. Purge npm cache by running npm cache clean --force and install packages again with npm install

Final thought: this issue is definitely related to the Python installed on our device, but I am not sure if it's a Python version or how the Python is installed.

1 Comment

I think instead of step #2, you can run conda deactivate to use the latest Python installed via homebrew, actually.
-1

It was a permissions problem for me. I was seeing this line before the errors:

gyp WARN EACCES current user ("ubuntu") does not have permission to access the dev dir "/root/.cache/node-gyp/14.15.4"

So I did chmod -R 777 /root then npm i sqlite3.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.