I tried the installation process, but I got this error (Note that I was using the --verbose flag)
[email protected] install C:\Users\testUser\Desktop\project\node_modules\better-sqlite3
> node deps/install
==> cwd: C:\Users\testUser\Desktop\project\node_modules\better-sqlite3
==> C:\Users\testUser\Desktop\project\node_modules\lzz-gyp\lzz-compiled\windows.exe -hx hpp -sx cpp -k BETTER_SQLITE3 -d -hl -sl -e ./src/better_sqlite3.lzz
==> cwd: C:\Users\testUser\Desktop\project\node_modules\better-sqlite3
==> node-gyp rebuild
C:\Users\testUser\Desktop\project\node_modules\better-sqlite3>if not defined npm_config_node_gyp (node "C:\Users\testUser\Desktop\project\node_modules\better-sqlite3\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
module.js:487
throw err;
^
Error: Cannot find module 'C:\Users\testUser\Desktop\project\node_modules\node-gyp\bin\node-gyp.js'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3
Error: exit code 1
at ChildProcess.<anonymous> (C:\Users\testUser\Desktop\project\node_modules\lzz-gyp\lib\exec.js:19:12)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
npm verb lifecycle [email protected]~install: unsafe-perm in lifecycle true
npm verb lifecycle [email protected]~install: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\testUser\Desktop\project\node_modules\better-sqlite3\node_modules\.bin;C:\Users\testUser\Desktop\project\node_modules\.bin;C:\Python27\;C:\Python27\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\AMD\ATI.ACE\Core-Static;C:\Users\testUser\AppData\Local\Android\sdk\tools;C:\Users\testUser\AppData\Local\Android\sdk\platform-tools;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Calibre2\;C:\Go\bin;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files\Java\jdk1.8.0_101\bin;C:\Program Files\dotnet\;C:\Program Files\MATLAB\R2016a\runtime\win64;C:\Program Files\MATLAB\R2016a\bin;C:\Program Files\MATLAB\R2016a\polyspace\bin;C:\opencv\mingw-build\bin;C:\mongodb\bin;C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin;C:\Program Files\PuTTY\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\nodejs\;C:\Ruby22-x64\bin;C:\Tcl\bin;C:\Users\testUser\AppData\Local\Microsoft\WindowsApps;C:\Users\testUser\AppData\Roaming\Composer\vendor\bin;C:\Program Files\Microsoft VS Code\bin;C:\Users\testUser\AppData\Roaming\npm
npm verb lifecycle [email protected]~install: CWD: C:\Users\testUser\Desktop\project\node_modules\better-sqlite3
npm info lifecycle [email protected]~install: Failed to exec install script
npm verb unlock done using C:\Users\testUser\AppData\Roaming\npm-cache\_locks\staging-f16103ef831cf6a0.lock for C:\Users\testUser\Desktop\project\node_modules\.staging
npm verb stack Error: [email protected] install: `node deps/install`
npm verb stack Exit status 1
npm verb stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:283:16)
npm verb stack at emitTwo (events.js:125:13)
npm verb stack at EventEmitter.emit (events.js:213:7)
npm verb stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
npm verb stack at emitTwo (events.js:125:13)
npm verb stack at ChildProcess.emit (events.js:213:7)
npm verb stack at maybeClose (internal/child_process.js:897:16)
npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
npm verb pkgid [email protected]
npm verb cwd C:\Users\testUser\Desktop\project
npm verb Windows_NT 10.0.15063
npm verb argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "better-sqlite3" "--verbose"
npm verb node v8.1.4
npm verb npm v5.0.3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node deps/install`
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 verb exit [ 1, true ]
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\testUser\Data\Roaming\npm-cache\_logs\2017-10-03T13_08_04_705Z-debug.log
Any help as to how to fix it?
Have you worked through this? https://github.com/JoshuaWise/better-sqlite3/wiki/Troubleshooting-installation
Although, for what it's worth, I have done everything listed in the guide above, spending hours on this, and it still doesn't work. Honestly, think it's best to just not even try unless you're on a Mac / Linux :(
@photonstorm we have plenty of windows users who have had no issues getting it working. Could you open a new ticket describing your problem?
@cr05s19xx Your error is pretty clear:
Cannot find module 'C:\Users\testUser\Desktop\project\node_modules\node-gyp\bin\node-gyp.js'
It looks like you don't have node-gyp installed, which is required for any native addon, not just better-sqlite3. If that doesn't work, try following the troubleshooting guide.
Any updates @cr05s19xx ?
Closing this as it seems to be abandoned by the OP.
Hunted for this issue a bit, I'm know commenting on a (fairly old) closed ticket is perhaps not the best, but here's what resolved the issue for me.
Doing npm i -g node_gyp did *not resolve it. it was still specifically complaining about it not being present in my current project's node_modules. Doing just npm i node_gyp however, installed node_gyp in my project, and then I was able to install better-sqlite3. I've seen other modules (like sqlite3, level, and others) build with node-gyp without requiring it to be installed in the same project, I wish I could point to what they're doing different but I really have no idea.
Also cannot install better-sqlite3. Very useful library, but such a pity, because canot install it.
`npm i better-sqlite3
[email protected] install C:\Users\user\node_modules\integer
node-gyp rebuild
C:\Users\user\node_modules\integer>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecyclenode-gyp-bin\....\node_modulesnode-gyp\binnode-gyp.js" rebuild ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modulesnode-gyp\binnode-gyp.js" rebuild )
Сборка проектов в этом решении по одному. Чтобы включить параллельную сборку, добавьте параметр "/m".
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(356,5): error MSB6006: "CL.exe" заве
ршилась с кодом -1073741515. [C:\Users\user\node_modules\integer\build\integer.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modulesnode-gyp\lib\build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\user\node_modules\integer
gyp ERR! node -v v10.13.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\user\package.json'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
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! C:\Users\user\AppData\Roaming\npm-cache_logs\2018-11-17T07_13_43_182Z-debug.log
`
So using this package requires casually installing 6gb of Windows-specific dependencies?
@Whired All native (C++) addons for Node.js require the same dependencies. There's nothing special that this package does. Blame Node, not better-sqlite3.
Please consider adjusting the "When is this library not appropriate?" section of the README to include this information.
As great as this solution would be, it's not feasible (in my case) due to the dependencies.
I was trying to install better-sqlite3 but kept getting errors about not finding VCBuild and MSBuild and installing node-gyp did not solve the problem
I initally tried to use npm install -g windows-build-tools which installed Visual Studio 2017 and did NOT include the v140 toolset and was then getting errors about this toolset (error MSB8020).
But Visual Studio 2015 does includes the v140 toolset...
You can force windows-build-tools to install VS2015 instead of VS2017 with this:
npm install --vs2015 -g windows-build-tools
internal/modules/cjs/loader.js:550
throw err;
^
Error: Cannot find module '../build/better_sqlite3.node'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
at Function.Module._load (internal/modules/cjs/loader.js:475:25)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at Object.<anonymous> (/rbd/pnpm-volume/45b2f77c-659a-41c9-b9b7-ed0d2c28c7ef/node_modules/.registry.npmjs.org/better-sqlite3/5.4.0/node_modules/better-sqlite3/lib/database.js:5:21)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
@eslachance
Having same issues on windows..
My project runs on node, but targeting to use it as an standalone browser app.. Does that mean better-sqlite3 wouldnt run on a browser?
@colradi Of course this will not work in the browser, it uses compiled C and C++. Webpack is not magic, it's an abomination that tricks people into thinking front-end and back-end are the same thing. Excuse me for getting emotional.
After reinstalling xcode-select, I could install better-sqlite3.
Most helpful comment
I was trying to install better-sqlite3 but kept getting errors about not finding VCBuild and MSBuild and installing node-gyp did not solve the problem
I initally tried to use
npm install -g windows-build-toolswhich installed Visual Studio 2017 and did NOT include the v140 toolset and was then getting errors about this toolset (error MSB8020).But Visual Studio 2015 does includes the v140 toolset...
You can force windows-build-tools to install VS2015 instead of VS2017 with this:
npm install --vs2015 -g windows-build-tools