0

So I've been working on this since yesterday, and can't seem to get anywhere. I've tried to follow documentation, and various tutorials but none of them seem to work.

If I make a new folder, with a new Javascript file with the default usage code:

var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database(':memory:');

db.serialize(function() {
  db.run("CREATE TABLE lorem (info TEXT)");

  var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
  for (var i = 0; i < 10; i++) {
      stmt.run("Ipsum " + i);
  }
  stmt.finalize();

  db.each("SELECT rowid AS id, info FROM lorem", function(err, row) {
      console.log(row.id + ": " + row.info);
  });
});

db.close();

And then try to install sqlite3 through npm by typing into the node.js CMD:

cd C:\Users\User\Desktop\Sqlite3test 
npm install sqlite3

I'm greeted with this error message:

C:\Users\User\Desktop\Sqlite3test>npm install sqlite3
\
> sqlite3@3.1.0 install C:\Users\User\node_modules\sqlite3
> node-pre-gyp install --fallback-to-build


C:\Users\User\node_modules\sqlite3>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" clean )  else (node  clean )

C:\Users\User\node_modules\sqlite3>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" configure --fallback-to-build --module=C:\Users\User\node_modules\sqlite3\lib\binding\node-v46-win32-x64\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\Users\User\node_modules\sqlite3\lib\binding\node-v46-win32-x64 --python=c:\Python27\python.exe )  else (node  configure --fallback-to-build --module=C:\Users\User\node_modules\sqlite3\lib\binding\node-v46-win32-x64\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\Users\User\node_modules\sqlite3\lib\binding\node-v46-win32-x64 --python=c:\Python27\python.exe )

C:\Users\User\node_modules\sqlite3>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" build --fallback-to-build --module=C:\Users\User\node_modules\sqlite3\lib\binding\node-v46-win32-x64\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\Users\User\node_modules\sqlite3\lib\binding\node-v46-win32-x64 )  else (node  build --fallback-to-build --module=C:\Users\User\node_modules\sqlite3\lib\binding\node-v46-win32-x64\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\Users\User\node_modules\sqlite3\lib\binding\node-v46-win32-x64 )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  unpack_sqlite_dep
  'python' is not recognized as an internal or external command,
  operable program or batch file.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targ
ets(170,5): error MSB6006: "cmd.exe" exited with code 1. [C:\Users\User\node_mo
dules\sqlite3\build\deps\action_before_build.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10240
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\User\\node_modules\\sqlite3\\lib\\binding\\node-v46-win32-x64\\node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=C:\\Users\\User\\node_modules\\sqlite3\\lib\\binding\\node-v46-win32-x64"
gyp ERR! cwd C:\Users\User\node_modules\sqlite3
gyp ERR! node -v v4.0.0
gyp ERR! node-gyp -v v3.0.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\Users\User\node_modules\sqlite3\lib\binding\node-v46-win32-x64\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\Users\User\node_modules\sqlite3\lib\binding\node-v46-win32-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\User\node_modules\sqlite3\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:87:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:817:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Windows_NT 10.0.10240
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\User\\node_modules\\sqlite3\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\User\node_modules\sqlite3
node-pre-gyp ERR! node -v v4.0.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.10
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\Users\User\node_modules\sqlite3\lib\binding\node-v46-win32-x64\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\Users\User\node_modules\sqlite3\lib\binding\node-v46-win32-x64' (1)
npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "sqlite3"
npm ERR! node v4.0.0
npm ERR! npm  v2.14.2
npm ERR! code ELIFECYCLE

npm ERR! sqlite3@3.1.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqlite3@3.1.0 install script 'node-pre-gyp install --fallback-to-build'.
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-pre-gyp install --fallback-to-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! Please include the following file with any support request:
npm ERR!     C:\Users\User\Desktop\Sqlite3test\npm-debug.log

Looking further through the documentation on the NPM website regarding sqlite3, it says that I must meet "node-gyp's requirements". I have gone through and done all of these. If I set up the python environment beforehand using:

npm config set python C:\Python27\python.exe

I get the same error message. I have no idea what's going on. Could it be because Windows 10 currently doesn't support the node-gyp requirements?

Constantly Confused
  • 595
  • 4
  • 10
  • 24

2 Answers2

0

Since you're on Windows, try

set PYTHON=python2.7
laike9m
  • 18,344
  • 20
  • 107
  • 140
  • I think you might be onto something. Due to the first line in the error being: "python not recognized as an internal..." Also, the requirements state that I must "Make sure that you have a PYTHON environment variable, and it is set to drive:\path\to\python.exe not to a folder". If I do "set PYTHON=C:\Python27\python.exe", it still throws the same error message. – Constantly Confused Sep 12 '15 at 12:05
0

Okay, so I found the solution.

It turned out that my Python environment variable was not correctly set. I looked it up on another thread and found this solution posted by Delicia Brummitt:

https://stackoverflow.com/a/21433154/4071682

Community
  • 1
  • 1
Constantly Confused
  • 595
  • 4
  • 10
  • 24