10

I'm running Pop!_OS (Ubuntu) 20.04. When I try to add sqlite3 to my dependencies on my nodejs project, I get this wall of warnings:

npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported

> [email protected] install /home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.1/napi-v6-linux-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v83 ABI, glibc) (falling back to source compile with node-gyp) 
make: Entering directory '/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/build'
  CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
  AR(target) Release/obj.target/../node-addon-api/nothing.a
  COPY Release/nothing.a
  ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3320300/sqlite3.c
/bin/sh: 1: python: not found
make: *** [deps/action_before_build.target.mk:13: Release/obj/gen/sqlite-autoconf-3320300/sqlite3.c] Error 127
make: Leaving directory '/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Linux 5.8.0-7630-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/lib/binding/napi-v6-linux-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/lib/binding/napi-v6-linux-x64" "--napi_version=7" "--node_abi_napi=napi" "--napi_build_version=6" "--node_napi_label=napi-v6"
gyp ERR! cwd /home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3
gyp ERR! node -v v14.15.4
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/lib/binding/napi-v6-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/lib/binding/napi-v6-linux-x64 --napi_version=7 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1048:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
node-pre-gyp ERR! System Linux 5.8.0-7630-generic
node-pre-gyp ERR! command "/usr/bin/node" "/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3
node-pre-gyp ERR! node -v v14.15.4
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/lib/binding/napi-v6-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/kevinlopez/Documents/Projects/wsky-be/node_modules/sqlite3/lib/binding/napi-v6-linux-x64 --napi_version=7 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6' (1)
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/kevinlopez/.npm/_logs/2021-01-17T06_26_58_042Z-debug.log

I've tried uninstalling and reinstalling npm and nodejs, deleting and reinstalling node_modules and package-lock.json, deleting ~/.node-gyp and running npm i -g node-gyp , and installing build essentials with sudo apt-get install -y build-essential

This is my package.json:

{
  "name": "wsky-be",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcrypt": "^5.0.0",
    "cors": "^2.8.5",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "express-session": "^1.17.1",
    "helmet": "^4.3.1",
    "knex": "^0.21.15"
  },
  "devDependencies": {
    "nodemon": "^2.0.7"
  }
}
3
  • 3
    /bin/sh: 1: python: not found ... kind of sticks out, no? Commented Jan 17, 2021 at 8:19
  • 1
    That was it. It's trying to run the python command which doesn't exist anymore on Ubuntu 20.04. I got around this by running sudo apt-get install python-is-python3 . This is only a temporary workaround, since it seems to replace any python command with the python3 command. I'll have to find something else when it needs to run a python2 command. Commented Jan 17, 2021 at 18:19
  • node-gyp is compatible with both Python 2 and 3 now, so you probably won't run into that particular issue at least with Node. Commented Jan 17, 2021 at 18:30

11 Answers 11

22

Pass the python path to the npm install proccess, that way the python will be found

npm install --build-from-source --python=/usr/bin/python3

Remember to put the desired python version, don't forget that python3 is the best choice nowadays. I used the path: /usr/bin/python3.8 and worked as well.

found this command at: github issue at node-sqlite3 repository

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

3 Comments

This did it for me. On Mac M1 Sonoma 14.1 python3 node 14/16, yarn install. yarn equivalent: npm_config_python=/usr/bin/python3 yarn install --build-from-source
still had issues on another workstation after running the above code. ended up just recloning the repo and adding python alias to .zshrc. export PATH="/usr/local/bin/python3:$PATH" alias python=python3
After 20 hours I found this snippet thank you
7

I think this issue comes from latest version of sqlite3. Try npm install [email protected] and use it. It works perfect for me

1 Comment

(current sqlite3 version = 5.0.1) ... For me "npm install [email protected]" worked
3

An alternative to symlinking python3 to python (which is what python-is-python3 does) would be setting the python variable in your npm config. Example: npm config set python /usr/local/bin/python3.

1 Comment

This fixed my issue when trying to npm install sqlite3 on a CircleCI build. The standard CircleCI container doesn't have python, only /usr/bin/python3. Relevent step: - run: npm config set python /usr/bin/python3
1

splite3 uses python 2.7 to build. Had the same problem. I had to set the path to python in the npm config. For me (on Linux) the solution was: npm config set python /usr/bin/python2

Then I was able to install sqlite3 successfully.

Comments

1

I also tried for hours to overcome the same setback but I solved it in 2 simple steps:

  1. npm rebuild

  2. npm i sqlite

It worked for me!

Comments

1

added version "sqlite3": "^4.1.1" in package.json and ran command

npm install --build-from-source --python=/usr/bin/python3

resolved the issue for me

Comments

0

And transferring comment to answer:

I suggest you install python (make it available), given the message /bin/sh: 1: python: not found.

Comments

0

do npm uninstall node-pre-gyp --save npm install @mapbox/node-pre-gyp --save npm install sqlite3

the above solved my issue.

1 Comment

cant even do that, same error when I try to uninstall node-pre-gyp
0

For anyone having this problem. I'm working with my Office PC where everything is restricted, therefore install this sqlite3 returns error as it requires compilation during npm install. Here's what I'm figure out:

    1. If my package.json has only "sqlite3": "^5.0.2" (no any other lib) then npm install works. But if I add all other libs that needs for my project + [email protected], remove nodes_modules, run npm install again, then it'll fail ->> solution for this is adding only "sqlite3": "^5.0.2" and run npm install first, then manually add other dependencies later and run npm install one more time, of course this is not a preferred way as we need to manually do
    1. downgrage to "sqlite3": "^4.1.1" fixed the problem, I can define sqlite3 with all other libs in my package.json -->> I'm going with this approach

Comments

0

Edit on 2022 : Mostly its not on python but the supported version of node

Please check the supported version of Node in sqlite npm documentation and use the supported Node version (mostly by downgrading using nvm)

For me the node verion is v16.x whereas the Sqlite max supported version is v12.x, so I downgraded and the issues went off!

Comments

0

For me the problem was fixed by removing the sqlite3 module and adding it again using a specific python version...

# The `websql` module was my only module using sqlite3.
# This will remove the actual `node_modules/sqlite3` folder...
yarn remove websql

# Tell npm which python version to use then add (and build) the module...
npm_config_python="/path/to/my/python/3.9/installation" yarn add [email protected]

# That's it!

Note: I use pyenv to manage my python versions. To get the path... pyenv which python3.9

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.