0

I'm very new to Node.JS and Node WebKit. I am trying to install the SQLite3 package for Node WebKit by following the instructions that the site has given me

https://github.com/mapbox/node-sqlite3

I am in my directory with my package.json file

{
    "name": "First",
    "description": "First attempt",
    "author": "Person",
    "main": "index.html",
    "window": {
        "toolbar": false,
        "width": 600,
        "height": 400
    },
    "license": "ISC"
}

And I did the first required command

npm install nw-gyp -g

which seems to have worked, then I tried to install the SQLite3 Module

npm install sqlite3 --build-from-source --runtime=node-webkit --target_arch=ia32 --target=$("0.12.3")

I also tried

npm install sqlite3 --runtime=node-webkit --target_arch=x64 --target=0.12.3

But this is failing and the log wasn't terribly helpful

2623 verbose pkgid sqlite3@3.1.1
2624 verbose cwd C:\PROG\NodeJS\Programs\NodeWebKit
2625 error Windows_NT 10.0.10586
2626 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "sqlite3" "--build-from-source" "--runtime=node-webkit" "--target_arch=ia32" "--target=$(0.12.3)"
2627 error node v4.2.5
2628 error npm  v2.14.12
2629 error code ELIFECYCLE
2630 error sqlite3@3.1.1 install: `node-pre-gyp install --fallback-to-build`
2630 error Exit status 1
2631 error Failed at the sqlite3@3.1.1 install script 'node-pre-gyp install --fallback-to-build'.
2631 error This is most likely a problem with the sqlite3 package,
2631 error not with npm itself.
2631 error Tell the author that this fails on your system:
2631 error     node-pre-gyp install --fallback-to-build
2631 error You can get their info via:
2631 error     npm owner ls sqlite3
2631 error There is likely additional logging output above.
2632 verbose exit [ 1, true ]
2633 verbose unbuild node_modules\sqlite3
2634 info preuninstall sqlite3@3.1.1
2635 info uninstall sqlite3@3.1.1
2636 verbose unbuild rmStuff sqlite3@3.1.1 from C:\PROG\NodeJS\Programs\NodeWebKit\node_modules
2637 info postuninstall sqlite3@3.1.1
2638 silly gentlyRm C:\PROG\NodeJS\Programs\NodeWebKit\node_modules\sqlite3 is being purged from base C:\PROG\NodeJS\Programs\NodeWebKit
2639 verbose gentlyRm don't care about contents; nuking C:\PROG\NodeJS\Programs\NodeWebKit\node_modules\sqlite3
2640 silly vacuum-fs purging C:\PROG\NodeJS\Programs\NodeWebKit\node_modules\sqlite3
2641 silly vacuum-fs removing C:\PROG\NodeJS\Programs\NodeWebKit\node_modules
2642 silly vacuum-fs finished vacuuming up to C:\PROG\NodeJS\Programs\NodeWebKit

Where do I start attempting to resolve this

UPDATE

This problem may be related to the nw-gyp. I ran

npm install nw-gyp -g

Which seemed ok but if I try to use it then I get an error, if I run

nw-gyp configure --target=0.12.3

I get an error

'nw-gyp' is not recognized as an internal or external command, operable program or batch file

UPDATE 02

I'm going to Install Visual Studio Express to see if this fixes it. This may take a long time

TheLovelySausage
  • 3,838
  • 15
  • 56
  • 106
  • 1
    Could be windows related. I've only ever used sqlite3 on linux. That being said, have you check nw-gyp is installed in %AppData%/npm/ (as a cmd or batch file) and the module itself under %AppData%/npm/node_modules? – chriskelly Jan 23 '16 at 12:56
  • It is there I double checked inside C:\Users\Admin\AppData\Roaming\npm which has nw-gyp as well as nw-gyp.bat and then C:\Users\Admin\AppData\Roaming\npm\node_modules\nw-gyp\gyp has gyp as well as gyp.bat – TheLovelySausage Jan 23 '16 at 13:04
  • 1
    and %NODE_PATH% is set to %AppData%\npm\node_modules? – chriskelly Jan 23 '16 at 13:13
  • No, this is my first time hearing of NODE_PATH o_o – TheLovelySausage Jan 23 '16 at 13:15
  • I set my environment using "set path=%path%;C:\Program Files\nodejs" and "set path=%path%;C:\Program Files\nodewebkit\nwjs-v0.12.3-win-x64" – TheLovelySausage Jan 23 '16 at 13:16
  • 1
    looking at those instructions, they seem to be for a linux system! all paths and commands are for linux . Does it say somewhere its supported on windows? – chriskelly Jan 23 '16 at 13:21
  • What makes you say that? – TheLovelySausage Jan 23 '16 at 13:23
  • 1
    The link you put in your post. I see lots of linux examples, some osx but no windows example or mention of windows. I just tried on windows and I get errors too. – chriskelly Jan 23 '16 at 13:25
  • I'm sure it's Windows though, they have Linux examples separately with the OSx ones and it's using the npm package which is platform independant – TheLovelySausage Jan 23 '16 at 13:27
  • 1
    good point! Do you have a compatile compiler installed to build it? e.g. visual studio. (http://stackoverflow.com/questions/21562038/node-gyp-build-error-windows-x64) – chriskelly Jan 23 '16 at 13:37
  • I have Python 2.7 but I need Visual Studio? – TheLovelySausage Jan 23 '16 at 13:39
  • 1
    Well, sqlite is built in c++. Under "On most linuxes" I see a bunch of c++ link and compile flags so I guess it's using gcc. On windows that's usually replaced by visual studio but sometimes mingw/gcc will do the job. – chriskelly Jan 23 '16 at 13:42
  • Wow, I guess I'll install Visual Studio. It's quite a beast of a download but if I'm going to do it I'll at least try do it right. Thanks for all your help I will put this on hold until the download is done – TheLovelySausage Jan 23 '16 at 13:44
  • 1
    Good luck! beast indeed. I don't see how else you will build sqlite on windows though (hope it;s not a wild goose chase). One last comment though ... Can you not use the prebuilt version? npm install sqlite3 works just fine for me (although I didn't try any sample code) – chriskelly Jan 23 '16 at 13:50

1 Answers1

1

I ran into similar problems as you did and I could fix it by doing the following.

Install Visual Studio Express 2012 or 2010. Afterwards Install Python and make sure that you set the build path. There is usually a option asking you to set the for you, if you use the installer.

Use the following command to install SQLite

npm install sqlite3 --build-from-source --runtime=node-webkit --target_arch=x64 --target="0.12.3" --save

Don't forget the --save as it will save the installation to your package.json. This is necessary for node-webkit to find it.

UPDATE With echo %PATH% in cmd you can see your path. Adding Python would look like this set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib Depending on where you installed python

carlspring
  • 31,231
  • 29
  • 115
  • 197
Silve2611
  • 2,198
  • 2
  • 34
  • 55
  • Hello, I've finally got VS Express Installed. I have Python 2.7 installed and in my path. What do I need to add to my path from Visual Studio? – TheLovelySausage Jan 24 '16 at 16:18
  • It is not the path from visual studio. That one is not relevant. Have you tried installing it. Is it working? The Path you have to add is the system path – Silve2611 Jan 24 '16 at 17:20
  • Wow it seems to have just installed with no problems after installing VS Express, I don't understand how but I'm just so stoked – TheLovelySausage Jan 24 '16 at 18:15
  • Haven't tried to implement the module in my Project yet but that may be a nightmare of it's own, I appreciate the help – TheLovelySausage Jan 24 '16 at 18:16