fritx / win-sqlcipher

Encrypted sqlite3 for Windows
https://www.npmjs.com/package/win-sqlcipher
9 stars 6 forks source link

cannot install package on Windows #3

Open Riokai opened 7 years ago

Riokai commented 7 years ago

os: Windows 7 node: v7.7.1 npm: 5.0.4

> sqlite3@3.1.4 install D:\Github\unix-sqlcipher\electron\node_modules\win-sqlcipher\node_modules\sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.4/node-v51-win32-x64.tar.gz

node-pre-gyp ERR! Pre-built binaries not found for sqlite3@3.1.4 and node@7.7.1 (node-v51 ABI) (falling back to source compile with node-gyp)
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\x64\PlatformToolsets\v140\Toolset.targets(36,5): error MSB803 6: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the pro ject property pages or by right-clicking the solution and selecting "Retarget solution". [D:\Github\unix-sqlcipher\electron\no de_modules\win-sqlcipher\node_modules\sqlite3\build\deps\action_before_build.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 (D:\Github\unix-sqlcipher\electron\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:194:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\Github\\unix-sqlcipher\\electron\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=D:\\Github\\unix-sqlcipher\\electron\\node_modules\\win-sqlcipher\\node_modules\\sqlite3\\lib\\binding\\node-v51-win32-x64\\node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=D:\\Github\\unix-sqlcipher\\electron\\node_modules\\win-sqlcipher\\node_modules\\sqlite3\\lib\\binding\\node-v51-win32-x64"
gyp ERR! cwd D:\Github\unix-sqlcipher\electron\node_modules\win-sqlcipher\node_modules\sqlite3
gyp ERR! node -v v7.7.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
Riokai commented 7 years ago

Btw, can you upgrade node-sqlite3 to latest (3.1.8)? Thx

fritx commented 7 years ago

@Riokai okay, will try soon.

gyp ERR! cwd D:\Github\unix-sqlcipher\electron\node_modules\win-sqlcipher\node_modules\sqlite3

The cwd looks weird. Could you try it directly in some path like D:\Github\win-sqlcipher\electron?

fritx commented 7 years ago
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1

Seems like you haven't installed the windows requirements. Try https://www.npmjs.com/package/windows-build-tools

Riokai commented 7 years ago

@fritx

First install windows-build-tools

λ npm install -g windows-build-tools

> windows-build-tools@1.3.2 postinstall C:\Users\Administrator\AppData\Roaming\npm\node_modules\windows-build-tools
> node ./lib/index.js

Downloading BuildTools_Full.exe
Downloading python-2.7.13.msi
[============================================>] 100.0% of 19.16 MB (628.23 kB/s)
Downloaded python-2.7.13.msi. Saved to C:\Users\Administrator\.windows-build-tools\python-2.7.13.msi.
Starting installation...
Launched installers, now waiting for them to finish.
This will likely take some time - please be patient!
Waiting for installers... -Successfully installed Python 2.7
Waiting for installers... /Successfully installed Visual Studio Build Tools.
+ windows-build-tools@1.3.2
added 127 packages in 173.737s

Second, switch to D:\Github\win-sqlcipher\

But still failed....

> sqlite3@3.1.8 install D:\Github\win-sqlcipher\node_modules\sqlite3                                                                  
> node-pre-gyp install --fallback-to-build                                                                                            

node-pre-gyp info it worked if it ends with ok                                                                                        
node-pre-gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',                                                                        
node-pre-gyp verb cli   'D:\\Github\\win-sqlcipher\\node_modules\\sqlite3\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp',            
node-pre-gyp verb cli   'install',                                                                                                    
node-pre-gyp verb cli   '--fallback-to-build' ]                                                                                       
node-pre-gyp info using node-pre-gyp@0.6.31                                                                                           
node-pre-gyp info using node@7.7.1 | win32 | x64                                                                                      
node-pre-gyp verb command install []                                                                                                  
node-pre-gyp info check checked for "D:\Github\win-sqlcipher\node_modules\sqlite3\lib\binding\node-v51-win32-x64\node_sqlite3.n       
ode" (not found)                                                                                                                      
node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.8/node-v51-win32-x64.tar.gz                            
node-pre-gyp http 200 https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.8/node-v51-win32-x64.tar.gz                            
node-pre-gyp info install unpacking node_sqlite3.node                                                                                 
node-pre-gyp info tarball done parsing tarball                                                                                        
node-pre-gyp info validate Running test command: 'C:\Program Files\nodejs\node.exe --eval 'require(\'D:/Github/win-sqlcipher/no       
de_modules/sqlite3/lib/binding/node-v51-win32-x64/node_sqlite3.node\')''                                                              
[sqlite3] Success: "D:\Github\win-sqlcipher\node_modules\sqlite3\lib\binding\node-v51-win32-x64\node_sqlite3.node" is installed       
 via remote                                                                                                                           
node-pre-gyp info ok                                                                                                                  

> win-sqlcipher@0.0.4 postinstall D:\Github\win-sqlcipher                                                                             
> node postinstall                                                                                                                    

npm WARN invalid config loglevel="notice"                                                                                             

> sqlite3@3.1.8 install D:\Github\win-sqlcipher\node_modules\sqlite3                                                                  
> node-pre-gyp install --fallback-to-build                                                                                            

node-pre-gyp info it worked if it ends with ok                                                                                        
node-pre-gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',                                                                        
node-pre-gyp verb cli   'D:\\Github\\win-sqlcipher\\node_modules\\sqlite3\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp',            
node-pre-gyp verb cli   'install',                                                                                                    
node-pre-gyp verb cli   '--fallback-to-build' ]                                                                                       
node-pre-gyp info using node-pre-gyp@0.6.31                                                                                           
node-pre-gyp info using node@7.7.1 | win32 | x64                                                                                      
node-pre-gyp verb command install []                                                                                                  
node-pre-gyp info build requesting source compile                                                                                     
node-pre-gyp verb command build [ 'rebuild' ]                                                                                         
�ڴ˽���������һ������һ����Ŀ����Ҫ���ò������ɣ������ӡ�/m�����ء�                                                                            
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\x64\PlatformToolsets\v140\Toolset.targets(36,5): error MSB8036       
: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the proje       
ct property pages or by right-clicking the solution and selecting "Retarget solution". [D:\Github\win-sqlcipher\node_modules\sq       
lite3\build\deps\action_before_build.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 (D:\Github\win-sqlcipher\node_modules\node-gyp\lib\build.js:258:23)                         
gyp ERR! stack     at emitTwo (events.js:106:13)                                                                                      
gyp ERR! stack     at ChildProcess.emit (events.js:194:7)                                                                             
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)                                          
gyp ERR! System Windows_NT 6.1.7601                                                                                                   
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\Github\\win-sqlcipher\\node_modules\\node-gyp\\bin\\node-gyp.js" "b       
uild" "--fallback-to-build" "--module=D:\\Github\\win-sqlcipher\\node_modules\\sqlite3\\lib\\binding\\node-v51-win32-x64\\node_       
sqlite3.node" "--module_name=node_sqlite3" "--module_path=D:\\Github\\win-sqlcipher\\node_modules\\sqlite3\\lib\\binding\\node-       
v51-win32-x64"                                                                                                                        
gyp ERR! cwd D:\Github\win-sqlcipher\node_modules\sqlite3                                                                             
gyp ERR! node -v v7.7.1                                                                                                               
gyp ERR! node-gyp -v v3.6.2                                                                                                           
gyp ERR! not ok                                                                                                                       
node-pre-gyp ERR! build error                                                                                                         
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe D:\Github\win-sqlcipher\node_modules\node-gy       
p\bin\node-gyp.js build --fallback-to-build --module=D:\Github\win-sqlcipher\node_modules\sqlite3\lib\binding\node-v51-win32-x6       
4\node_sqlite3.node --module_name=node_sqlite3 --module_path=D:\Github\win-sqlcipher\node_modules\sqlite3\lib\binding\node-v51-       
win32-x64' (1)                                                                                                                        
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (D:\Github\win-sqlcipher\node_modules\sqlite3\node_modules\node-pre-gyp       
\lib\util\compile.js:83:29)                                                                                                           
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)                                                                             
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:194:7)                                                                    
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:899:16)                                                          
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)                                  
node-pre-gyp ERR! System Windows_NT 6.1.7601                                                                                          
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\Github\\win-sqlcipher\\node_modules\\sqlite3\\node_modules       
\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"                                                                    
node-pre-gyp ERR! cwd D:\Github\win-sqlcipher\node_modules\sqlite3                                                                    
node-pre-gyp ERR! node -v v7.7.1                                                                                                      
node-pre-gyp ERR! node-pre-gyp -vFailed to execute 'C:\Program Files\nodejs\node.exe D:\Github\win-sqlcipher\node_modules\node-       
gyp\bin\node-gyp.js build --fallback-to-build --module=D:\Github\win-sqlcipher\node_modules\sqlite3\lib\binding\node-v51-win32-       
x64\node_sqlite3.node --module_name=node_sqlite3 --module_path=D:\Github\win-sqlcipher\node_modules\sqlite3\lib\binding\node-v5       
1-win32-x64' (1)                                                                                                                      
 v0.6.31                                                                                                                              
node-pre-gyp ERR! not ok                                                                                                              
npm ERR! code ELIFECYCLE                                                                                                              
npm ERR! errno 1                                                                                                                      
npm ERR! sqlite3@3.1.8 install: `node-pre-gyp install --fallback-to-build`                                                            
npm ERR! Exit status 1                                                                                                                
npm ERR!                                                                                                                              
npm ERR! Failed at the sqlite3@3.1.8 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\Administrator\AppData\Roaming\npm-cache\_logs\2017-06-27T08_28_34_990Z-debug.log                                
npm WARN win-sqlcipher@0.0.4 No license field.                                                                                        
fritx commented 7 years ago

Try to install Visual Studio 2015 :joy: https://github.com/mapbox/node-sqlite3/blob/master/appveyor.yml https://github.com/mapbox/node-sqlite3/blob/master/scripts/build-appveyor.bat

Builds against electron is not provided by node-pre-gyp, so we have to build it ourselves. (I'll also try to setup some CI to automatically build for electron if I have time.)

fritx commented 7 years ago

I have a Windows7 computer that already has everything set up, if you need, I might be able to build a target for you.

Riokai commented 7 years ago

This seem weird, if run npm install sqlite3@latest directly on Windows 7 computer, everything is okay.

fritx commented 7 years ago

Yeah, as I said, node-pre-gyp have cached sqlite3@latest (with node) for you, where you don't need to build yourself on your computer.

However, what you should run instead, is:

npm i sqlite3@latest && electron-rebuild # you should rebuild for electron
Riokai commented 7 years ago

Gotcha, I appreciate if u can build a target for me. 😁

fritx commented 7 years ago

I'm not sure does it work for you, try to place it in your sqlite3/lib/binding directory. I've built one for electron v1.7. https://github.com/fritx/win-sqlcipher/tree/build/node_modules/sqlite3/lib/binding

Riokai commented 7 years ago

I've install visual studio 2015 and build binary successful, but electron throw an error.

And path is correct, file is exist.

Please help me.

@fritx

ELECTRON_ASAR.js:173 Uncaught Error: The specified module could not be found.
\\?\D:\Github\win-sqlcipher\node_modules\sqlite3\lib\binding\electron-v1.7-win32-x64\node_sqlite3.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\Github\win-sqlcipher\node_modules\sqlite3\lib\sqlite3.js:4:15)
    at Object.<anonymous> (D:\Github\win-sqlcipher\node_modules\sqlite3\lib\sqlite3.js:189:3)

Build Info

   正在创建库 D:\Github\win-sqlcipher\node_modules\sqlite3\build\Release\node_sqlite3.lib 和对象 D:\Github\win-sqlcipher\node_
modules
  \sqlite3\build\Release\node_sqlite3.exp
  正在生成代码
  已完成代码的生成
  node_sqlite3.vcxproj -> D:\Github\win-sqlcipher\node_modules\sqlite3\build\Release\\node_sqlite3.node
  node_sqlite3.vcxproj -> D:\Github\win-sqlcipher\node_modules\sqlite3\build\Release\node_sqlite3.pdb (Full PDB)
  Copying D:\Github\win-sqlcipher\node_modules\sqlite3\build\Release\/node_sqlite3.node to D:/Github/win-sqlcipher/node_module
  s/sqlite3/lib/binding/node-v51-win32-x64\node_sqlite3.node
  已复制         1 个文件。

> electron@1.7.4 postinstall D:\Github\win-sqlcipher\node_modules\electron
> node install.js

npm WARN win-sqlcipher@0.0.4 No license field.

added 235 packages in 124.037s

D:\Github\win-sqlcipher (build) (win-sqlcipher@0.0.4)
λ npm run electron-build

> win-sqlcipher@0.0.4 electron-build D:\Github\win-sqlcipher
> electron-rebuild -w . -v 1.7.0

√ Rebuild Complete
Riokai commented 7 years ago

I try to download your binary file and replace mine, same result.

fritx commented 7 years ago

@Riokai yeah, same issue as #2.

I have to figure out what steps are missing.

One year ago I setup everything and have my computer build for electron and everything successfully.

Seems have something to do with OpenSSL.

sai-kyaw commented 7 years ago

@fritx - First of all, thanks for your hard work on this module. Is it working on electron now?

I am unable to get it working on electron 1.7.5 on Windows. (also tested with your prebuild for electron).

I am getting this error:

Uncaught Error: error: 126\\?\C:\Users\*\Desktop\electron-quick-start\node_modules\win-sqlcipher\node_modules\sqlite3\lib\binding\electron-v1.7-win32-x64\node_sqlite3.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)

Would you be able to help out?

Appreciated,

sai-kyaw commented 7 years ago

Never mind, it's working on windows both node and electron now. Thanks.

fritx commented 7 years ago

@sai-kyaw awesome! What did you do to solve it?

sai-kyaw commented 7 years ago

@fritx ... Are you guys still having issue with the window builds? The problem is resolved by installing VS2013 instead of 2015 which is windows-build-tools default. Because when I built sqlcipher itself with MS Build tools 2015, yet it's still looking for MSVCR120.dll which is included in VS2013. I'm not sure if this is something to do with sqlite's configuration for windows build.

So look for MSVCR120.dll is in system32 folder, if not I would recommend to install VS2013.

Let me know if installing vs2013 doesn't resolve the issue. I was also playing around with openssl.

Oh I also use electron builder instead of electron-rebuild. Add "postinstall": "electron-builder install-app-deps", to scripts block in your package.json.

I've tested the build on windows - 8.1, 10 and server 2012. electron - 1.7.5 and 1.7.8

Best of luck.

alangrainger commented 7 years ago

Thanks to @sai-kyaw, here are full working instructions:

I got the DLL files from DB Browser for SQLite Windows build, and copied them to System32, and it compiled just fine!

Here are the DLLs for anyone else who needs them: https://drive.google.com/file/d/0BwEyNB4Ss8kjLWVDVHFCVkRLT2s/view?usp=sharing

Environment:

Steps:

  1. Copy DLLs to System32
  2. Install Windows Build Tools if you don't have them - npm install -g windows-build-tools
  3. npm install
  4. .\node_modules\.bin\electrion-rebuild

Note: I got this error while installing even though I have the package specified in my packages.json:

npm ERR! missing: nan@~2.3.3, required by sqlite3@3.1.4

It did not however prevent the successful compilation and running of my app. Likely something needs to be fixed, but I'm not sure what.

sai-kyaw commented 7 years ago

@alangrainger Brilliant!

Just wondering if you have MSVCR120.dll in your System32?

You also need to include those DLLs in your final EXE, otherwise it won't run on the systems which don't have them installed.

alangrainger commented 7 years ago

@sai-kyaw - yes I do have that, but I did not add it for this project.

I noticed the same thing about the DLLs not being in the EXE when I tested my built app on another laptop. I've added this to my packages.json but haven't tested it yet:

"build": {
  "extraFiles": "build/lib/*.dll"
}
alangrainger commented 7 years ago

Solved

This code works for including the DLLs:

"extraFiles": "./*.dll"

fritx commented 7 years ago

@alangrainger @sai-kyaw amazing, guys!