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

[win] node native module doesn't work with renamed exe (was node-sqlite3 module don't work in node-webkit package mode) #199

Closed
bicio opened this Issue Nov 20, 2012 · 56 comments

Comments

Projects
None yet
@bicio

bicio commented Nov 20, 2012

I've a problem with node-webkit v0.3.4 and node-sqlite3 module.
So, if I run my app with command nw C:\apps\packagedapp.nw my application work fine,
but if I create a package by command copy /b nw.exe+app.nw app.exe and launch it, my application crash whit error : Uncaught error: no error myPAth/node_sqlite3.node.

someone could help me
thanks

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@rogerwang

This comment has been minimized.

Member

rogerwang commented Nov 20, 2012

Can you provide the exact full error message? Thanks

@risingphoenix

This comment has been minimized.

risingphoenix commented Nov 20, 2012

happens to me too

nw v.0.3.2 , node_module compiled with your nw-gyp

here's my console error message

Uncaught Error: no error [%temporary directory%]\nw2340_27604\node_modules\sqlite3\node_sqlite3.node
source and line
module.js:485

thanks in advance

@bicio

This comment has been minimized.

bicio commented Nov 20, 2012

the error is in the function Module._extensions['.node'] in the module.js file in line 485

@bicio

This comment has been minimized.

bicio commented Nov 20, 2012

Hi, I try monolighter solution but i can't create a correct app.exe because when I start it node-webkit show nw:blank page.
I don't understand where I was wrong.. :-(

@rogerwang

This comment has been minimized.

Member

rogerwang commented Nov 20, 2012

This could be a bug . I'll see what I can find and get back to you.

-------- Original Message --------
From: bicio notifications@github.com
Sent: Wed Nov 21 00:01:41 格林尼治标准时间+0800 2012
To: rogerwang/node-webkit node-webkit@noreply.github.com
Cc: Roger Wang wenrui@gmail.com
Subject: Re: [node-webkit] node-sqlite3 module don't work in node-webkit package mode (windows) (#199)

Hi, I try monolighter solution but i can't create a correct app.exe because when I start it node-webkit show nw:blank page.
I don't understand where I was wrong.. :-(


Reply to this email directly or view it on GitHub:
#199 (comment)

@bicio

This comment has been minimized.

bicio commented Nov 20, 2012

thank you very much

@risingphoenix

This comment has been minimized.

risingphoenix commented Nov 20, 2012

@monolighter as specified in the wiki, the plugin:true flag is useful for plugins like flash, not for nodejs modules

@rogerwang

This comment has been minimized.

Member

rogerwang commented Nov 21, 2012

My wild guess is that the module DLL wants its dependency -- nw.exe, but after packaging, 'nw.exe' is renamed.

@Mithgol

This comment has been minimized.

Contributor

Mithgol commented Nov 21, 2012

This guess could be tested by placing nw.exe beside app.exe to see what happens.

@rogerwang

This comment has been minimized.

Member

rogerwang commented Nov 21, 2012

or just name the app executable nw.exe.

@bicio

This comment has been minimized.

bicio commented Nov 21, 2012

if I rename my app.exe in nw.exe work fine!

@ghost ghost assigned rogerwang Nov 30, 2012

@everyonme

This comment has been minimized.

everyonme commented Dec 5, 2012

can i package .dll files with nw.exe and app.zip together ?

@patrickklug

This comment has been minimized.

patrickklug commented Aug 2, 2013

We are just about to integrate some custom node.js plugins and will run into this issue as well. Is there any plan to fix this in the near future? Could Gnor help with this?

@GnorTech

This comment has been minimized.

Member

GnorTech commented Aug 3, 2013

Yeah. It can be done via rebuild on windows.

@lvbeck

This comment has been minimized.

lvbeck commented Sep 10, 2013

any update for this 10 months old bug?

@startry

This comment has been minimized.

startry commented Sep 22, 2013

is this problem had been fixed ?! @lvbeck @rogerwang @theabraham

@theabraham

This comment has been minimized.

Contributor

theabraham commented Oct 4, 2013

No, I don't think so :/

@risingphoenix

This comment has been minimized.

risingphoenix commented Dec 10, 2013

Any planning for the fix of this error?
Is there already any good solution?

@mese79

This comment has been minimized.

mese79 commented Feb 7, 2014

Hi
Any update for this bug yet?
It is really annoying all app must have nw.exe name.

@SingKo

This comment has been minimized.

SingKo commented Feb 8, 2014

Is there any plan to fix this bug? @rogerwang

@rogerwang

This comment has been minimized.

Member

rogerwang commented Feb 8, 2014

@SingKo Since the issue is open, it's planned to be fixed. But there is no schedule yet.

@adam-lynch

This comment has been minimized.

adam-lynch commented Mar 7, 2015

Does this problem still exist?

@LiamKarlMitchell

This comment has been minimized.

LiamKarlMitchell commented Apr 1, 2015

Can't we just get the program name at run-time and pass it to the module after its loaded if it is really required?


In Example:
OllyDBG and IDA Pro plugins have it so the plugin will have a method exposed which is called by the process loading the plugin and will be used pass over anything required, including version numbers to check if the plugin was compiled for that version of the plugin api.

So for windows targets just export a hidden function like __nwmodule_init and give it the runtime information required. It should reply with the version of node webkit/ application binary interface it was compiled for then node webkit even if it is renamed could say yes or no to the module loading.

Or am I misunderstanding the complexity of this issue?
I may give it a go if this is still a problem.

@etx

This comment has been minimized.

etx commented Apr 10, 2015

This bug is really bumming me out.

@rogerwang

This comment has been minimized.

Member

rogerwang commented Apr 10, 2015

In NW13 we are splitting the code as Chrome does on windows: ship nw.exe and nw.dll. Third party modules will be linking with nw.dll. Then the renaming of nw.exe won't break it.

@LiamKarlMitchell

This comment has been minimized.

LiamKarlMitchell commented Apr 10, 2015

that is a good idea if the same version is used on a system it will get around duplication of core functionality.

Just a thought, rather than copying the nw exe each time, it may be possible to make a shell extension/registry key on windows (i am not sure about other systems) to register a file extension that would run nw.exe on the directory or package / package.json chosen.

Similar to how java has jar files that can be opened in javaw by double clicking.
Is this something that has been considered or already done i must read more.

If a particular version of nw is required the package.json could say so and some sort of loader could load that core functionality to handle the process.

@etx

This comment has been minimized.

etx commented Apr 10, 2015

Great to hear Roger! Thanks for your hard work.

@ArielBadichi

This comment has been minimized.

ArielBadichi commented May 13, 2015

Until we get nw.dll, maybe this can help: NW.js with a custom executable name and native modules.

@morgondag

This comment has been minimized.

morgondag commented May 14, 2015

@ArielBadichi nice! will test it out!

@githubuserxj

This comment has been minimized.

githubuserxj commented Jun 8, 2015

@SingKo
how to rebuild nw with ninja.
Can you give us a more detailed step by step ?
thanks.

@doruchiulan

This comment has been minimized.

doruchiulan commented Aug 28, 2015

for me it doesnt work even if I rename the resulting exe from nw-builder to nw.exe. If I put my app files in the folder where original nw lives it works.

I am using leveldown in my app.

@asinbow

This comment has been minimized.

asinbow commented Nov 20, 2015

The killer solution seems to provide a PE manipulating tool to modify import table.
portable-executable-library or exported under my name looks great.
Since it supports:

  • Read 32- and 64-bit PE files (PE, PE+) for Windows, work similar with both formats
  • Read and write imports

You can see my demo nw-addon-demo.
It's tested OK for both ia32 and amd64.

@angufix

This comment has been minimized.

angufix commented Dec 15, 2015

Just renamed the nw.js to myapp.exe and run the exe file, the sqlite3(native module) can't handle it. Error log:

[8480:1215/172020:ERROR:gpu_child_thread.cc(146)] Exiting GPU process due to errors during initialization
[9188:1215/172020:ERROR:nw_shell.cc(335)] Error: The specified module could not be found.
C:\myapp\node_modules\sqlite3\lib\binding\node-webkit-v0.12.2-win32-ia32\node_sqlite3.node
at Error (native)
at Module.load (module.js:346:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:356:17)
at require (module.js:375:17)
at Object. (C:\myapp\node_modules\sqlite3\lib\sqlite3.js:4:15)
at Module._compile (module.js:451:26)
at Object.Module._extensions..js (module.js:469:10)
at Module.load (module.js:346:32)
at Function.Module._load (module.js:301:12)
[9188:1215/172020:INFO:CONSOLE(346)] "Uncaught Error: The specified module could not be found.
C:\myapp\node_modules\sqlite3\lib\binding\node-webkit-v0.12.2-win32-ia32\node_sqlite3.node", source: module.js (346)

@asinbow

This comment has been minimized.

asinbow commented Dec 20, 2015

@angufix Windows reports a dll module not found if any of its dependency not found. Your node_sqlite3.node depends on nw.exe, so it will fail when you rename nw.exe. You can see my sample code nw-addon-demo. There is a utility tool:

rename_import_lib\rename_import_lib.exe -i <path-to-node> [-o <path-to-output>] -r nw.exe <your-new-exe-name>

for your case

rename_import_lib\rename_import_lib.exe -i node_sqlite3.node -r nw.exe myapp.exe

Source code of rename_import_lib\rename_import_lib.exe also provided. It uses libpebliss.

@rogerwang

This comment has been minimized.

Member

rogerwang commented Feb 29, 2016

This is supported in 0.13 now. Native modules depends on node.dll and nw.dll. And you can control the dependency. See more information here: https://groups.google.com/d/msg/nwjs-general/UqEq8ito2gI/W-ld9LSoDQAJ

@rogerwang rogerwang closed this Feb 29, 2016

@wozzup

This comment has been minimized.

wozzup commented Mar 23, 2016

@dannatofrenk

This comment has been minimized.

dannatofrenk commented Oct 5, 2016

Hello guys, sorry to write on this old thread, but nw-gyp is too much for me, I'm left with no developers and trying to build myself is no use. According to the developers our application requires
nw-gyp 0.12.3
sqlite3 is built succesfully but seems misplaced in windows builds:
the usual:

Uncaught Error: Cannot find module 'C:\Users\F6FAA~1.CHI\AppData\Local\Temp\nw3056_13763\node_modules\sqlite3\lib\binding\node-webkit-v0.12.3-win32-x64\node_sqlite3.node'

The app has been previously built successfully on linux 64 and working correcly.

After days of trying on a very steep learning curve, I'm here to ask to HIRE someone of you who would compile for windows. Please show up if available or give a few hints.

the environment I used:
node 5.6.0 (installed globally)
npm 3.6.0
python2.7
nw-gyp 3.4.0
node-pre-gyp 0.6.30
OS windows 7 professional
VStudio 2013

Set python path: npm config set python /Python27/python.exe --global

I removed every vs and c++ compiler from windows and installed vs express 2013 and set the environment variables.
"%VS120COMNTOOLS%"\vsvars32.bat // VS2013 environment variables with this from vs cmd worked.

Run visual studio shell as administrator.

The command I run
npm install;
npm run build;

cd build ; npm i :
cd ..
node nw-build.js (setting architecture and version win64, 0.12.3 )

I tried also to build separately and in the build directory
npm install sqlite3 --build-from-source --runtime=node-webkit --target_arch=ia32 --target="0.12.3"

I tryed to rename nw.exe myapp.exe but still the same error
.
Question: Should I use the module rename_import lib? or install nwjs instead of nw-gyp ?
at the moment I'm out of ideas

You are welcome for hire to build/document or for directions

Thank you
F

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