Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for nw.js #65

Closed
Silve2611 opened this issue Sep 7, 2017 · 7 comments
Closed

Support for nw.js #65

Silve2611 opened this issue Sep 7, 2017 · 7 comments

Comments

@Silve2611
Copy link

NW.js is like electron but has some advantages like code protection etc.

However better-sqlite3 ist not running with nw.js. Here the error

174 verbose lifecycle better-sqlite3@4.0.2install: unsafe-perm in lifecycle true
175 verbose lifecycle better-sqlite3@4.0.2
install: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/timebro/timeBro/git/mac/front/timeBro.app/Contents/Resources/app.nw/node_modules/better-sqlite3/node_modules/.bin:/Users/timebro/timeBro/git/mac/front/timeBro.app/Contents/Resources/app.nw/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
176 verbose lifecycle better-sqlite3@4.0.2install: CWD: /Users/timebro/timeBro/git/mac/front/timeBro.app/Contents/Resources/app.nw/node_modules/better-sqlite3
177 silly lifecycle better-sqlite3@4.0.2
install: Args: [ '-c', 'node deps/install' ]
178 silly lifecycle better-sqlite3@4.0.2install: Returned: code: 1 signal: null
179 info lifecycle better-sqlite3@4.0.2
install: Failed to exec install script
180 verbose unlock done using /Users/timebro/.npm/_locks/staging-ab38ca7a6a6822fb.lock for /Users/timebro/timeBro/git/mac/front/timeBro.app/Contents/Resources/app.nw/node_modules/.staging
181 warn timeBro@1.2.2 No description
182 warn timeBro@1.2.2 No repository field.
183 warn timeBro@1.2.2 license should be a valid SPDX license expression
184 verbose stack Error: better-sqlite3@4.0.2 install: node deps/install
184 verbose stack Exit status 1
184 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:280:16)
184 verbose stack at emitTwo (events.js:125:13)
184 verbose stack at EventEmitter.emit (events.js:213:7)
184 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
184 verbose stack at emitTwo (events.js:125:13)
184 verbose stack at ChildProcess.emit (events.js:213:7)
184 verbose stack at maybeClose (internal/child_process.js:887:16)
184 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
185 verbose pkgid better-sqlite3@4.0.2
186 verbose cwd /Users/timebro/timeBro/git/mac/front/timeBro.app/Contents/Resources/app.nw
187 verbose Darwin 16.6.0
188 verbose argv "/usr/local/Cellar/node/8.0.0_1/bin/node" "/usr/local/bin/npm" "install" "better-sqlite3" "--save"
189 verbose node v8.0.0
190 verbose npm v5.4.0
191 error code ELIFECYCLE
192 error errno 1
193 error better-sqlite3@4.0.2 install: node deps/install
193 error Exit status 1
194 error Failed at the better-sqlite3@4.0.2 install script.
194 error This is probably not a problem with npm. There is likely additional logging output above.
195 verbose exit [ 1, true ]

@dmidjakov
Copy link

Still no decision?

@JoshuaWise
Copy link
Member

I don't really plan on investigating the installation issues related to Electron, nw.js, etc. As far as I'm concerned better-sqlite3 is a Node.js package, and if third parties like Electron claim to support Node.js, it's their problem when they fail to satisfy that promise. I imagine that issues with nw.js are similar to issues with Electron, which I've delegated to a special thread here. If the Electron or nw.js community is passionate enough to solve these problems, I welcome the support.

@Silve2611
Copy link
Author

I can understand that you don‘t have the time to do that. Yet I would recommend to leave the case open if you change your mind in the fufure.
Nw.js and electron are ok the rise and SQLite fits perfectly for their needs. The propability to use it is much high than on node.js servers that can easily use mysql instead.
Your framework would find a large user base where you could easily find someone to help you keeping track with nw.js and electron versions ;)

@fusionstream
Copy link

Just to be clear, nwjs isn't quite like electron in this regard. Modules need to be built from source with nw-gyp. I've tried replacing 'sqlite3' with 'better-sqlite3' in the commands stated on the sqlite3 documentation but had no luck. If I get it working, I'll post back.

@yassinevic
Copy link

yassinevic commented Jul 28, 2018

For me it compiles without any error "nw-gyp rebuild --target=0.29.3 --arch=x64". but running the exemple code causes nw.js to crash with no logs or anything.
i was not able to go further.
nw.js version 0.29.3-win-x64
C:\PlayGround\package.nw\node_modules\better-sqlite3>nw-gyp rebuild --target=0.29.3 --arch=x64 --msvs_version=2015 gyp info it worked if it ends with ok gyp info using nw-gyp@3.6.3 gyp info using node@8.11.1 | win32 | x64 gyp info spawn C:\Users\HP\.windows-build-tools\python27\python.EXE gyp info spawn args [ 'C:\\Users\\HP\\AppData\\Roaming\\npm\\node_modules\\nw-gyp\\gyp\\gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'msvs', gyp info spawn args '-G', gyp info spawn args 'msvs_version=2015', gyp info spawn args '-I', gyp info spawn args 'C:\\PlayGround\\\package.nw\\node_modules\\better-sqlite3\\build\\config.gypi', gyp info spawn args '-I', gyp info spawn args 'C:\\Users\\HP\\AppData\\Roaming\\npm\\node_modules\\nw-gyp\\addon.gypi', gyp info spawn args '-I', gyp info spawn args 'C:\\Users\\HP\\.nw-gyp\\0.29.3\\common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=C:\\Users\\HP\\.nw-gyp\\0.29.3', gyp info spawn args '-Dnode_gyp_dir=C:\\Users\\HP\\AppData\\Roaming\\npm\\node_modules\\nw-gyp', gyp info spawn args '-Dnode_lib_file="C:\\Users\\HP\\.nw-gyp\\0.29.3\\<(target_arch)\\node.lib"', gyp info spawn args '-Dnw_lib_file="C:\\Users\\HP\\.nw-gyp\\0.29.3\\<(target_arch)\\nw.lib"', gyp info spawn args '-Dmodule_root_dir=C:\\PlayGround\\package.nw\\node_modules\\better-sqlite3', gyp info spawn args '-Dnode_engine=v8', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '-Dv13=1', gyp info spawn args '--generator-output', gyp info spawn args 'C:\\PlayGround\\package.nw\\node_modules\\better-sqlite3\\build', gyp info spawn args '-Goutput_dir=.' ] gyp info spawn C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe gyp info spawn args [ 'build/binding.sln', gyp info spawn args '/clp:Verbosity=minimal', gyp info spawn args '/nologo', gyp info spawn args '/p:Configuration=Release;Platform=x64' ] Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. unpack_sqlite_dep sqlite3.c win_delay_load_hook.cc sqlite3.vcxproj -> C:\PlayGround\package.nw\node_modules\better-sqlite3\build\Release\\sqlite3.lib better_sqlite3.cpp win_delay_load_hook.cc Creating library C:\PlayGround\package.nw\node_modules\better-sqlite3\build\Release\better_sqlite3.lib and object C:\PlayGround\package.nw\node_modules\better-sqlite3\build\Release\better_sqlite3.exp Generating code All 4032 functions were compiled because no usable IPDB/IOBJ from previous compilation was found. Finished generating code better_sqlite3.vcxproj -> C:\PlayGround\package.nw\node_modules\better-sqlite3\build\Release\\better_sqlite3. node better_sqlite3.vcxproj -> C:\PlayGround\package.nw\node_modules\better-sqlite3\build\Release\better_sqlite3.p db (Full PDB) test_extension.c win_delay_load_hook.cc Generating code All 2 functions were compiled because no usable IPDB/IOBJ from previous compilation was found. Finished generating code test_extension.vcxproj -> C:\PlayGround\package.nw\node_modules\better-sqlite3\build\Release\\test_extension. node test_extension.vcxproj -> C:\PlayGround\package.nw\node_modules\better-sqlite3\build\Release\test_extension.p db (Full PDB) gyp info ok

@131
Copy link

131 commented Dec 4, 2018

sames goes for me nw-gyp rebuild --target=0.26.0 --arch=ia32 --verbose

@gelprec
Copy link

gelprec commented Sep 14, 2021

I managed to install better-sqlite3 on windows 10 using the last 0.56 nwjs version and everything seems fine. The following steps worked for me:

  1. Prerequisites: Python 2.7 and windows-build-tools (via windows-build-tools - npm)

  2. Start with a fresh nwjs folder, create the package.json file (in my case the entry point is an index.html file)

  3. cd to the nwjs folder and execute the powershell multiple command

    npm install -g nw-gyp; set PYTHON=C:\Python27\python.exe; set npm_config_target=0.56.0; set npm_config_arch=x64; set npm_config_runtime=node-webkit; set npm_config_build_from_source=true; set npm_config_target_arch=x64; set npm_config_node_gyp=C:\Users\Geo\AppData\Roaming\npm\node_modules\nw-gyp\bin\nw-gyp.js; npm install better-sqlite3
    

    npm_config_target is the nwjs version and npm_config_node_gyp is the path to nw-gyp.js from the global installation of nw-gyp (these values ​​must be set according to the specifics of each user) .

  4. cd to the better-sqlite3 folder from node_modules and execute the powershell command

    nw-gyp rebuild --target=0.56.0 --arch=x64
    

According to Use Native Node Modules - NW.js Documentation the steps 1-3 should have been enough but, for some reason, step 4 was also needed in my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

7 participants