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

[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
Assignees
Labels

Comments

@bicio
Copy link

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
Copy link
Member

Can you provide the exact full error message? Thanks

@risingphoenix
Copy link

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
Copy link
Author

bicio commented Nov 20, 2012

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

@bicio
Copy link
Author

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
Copy link
Member

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
Copy link
Author

bicio commented Nov 20, 2012

thank you very much

@risingphoenix
Copy link

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

@rogerwang
Copy link
Member

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

@Mithgol
Copy link
Contributor

Mithgol commented Nov 21, 2012

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

@rogerwang
Copy link
Member

or just name the app executable nw.exe.

@bicio
Copy link
Author

bicio commented Nov 21, 2012

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

@ghost ghost assigned rogerwang Nov 30, 2012
@everyonme
Copy link

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

@patrickklug
Copy link

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
Copy link
Member

GnorTech commented Aug 3, 2013

Yeah. It can be done via rebuild on windows.

@lvbeck
Copy link

lvbeck commented Sep 10, 2013

any update for this 10 months old bug?

@startry
Copy link

startry commented Sep 22, 2013

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

@theabraham
Copy link
Contributor

No, I don't think so :/

@risingphoenix
Copy link

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

@mese79
Copy link

mese79 commented Feb 7, 2014

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

@SingKo
Copy link

SingKo commented Feb 8, 2014

Is there any plan to fix this bug? @rogerwang

@rogerwang
Copy link
Member

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

@adam-lynch
Copy link

Does this problem still exist?

@LiamKarlMitchell
Copy link

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
Copy link

etx commented Apr 10, 2015

This bug is really bumming me out.

@rogerwang
Copy link
Member

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
Copy link

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
Copy link

etx commented Apr 10, 2015

Great to hear Roger! Thanks for your hard work.

@ArielBadichi
Copy link

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

@morgondag
Copy link

@ArielBadichi nice! will test it out!

@githubuserxj
Copy link

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

@doruchiulan
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link
Member

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

@wozzup
Copy link

wozzup commented Mar 23, 2016

@dannatofrenk
Copy link

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
Labels
Projects
None yet
Development

No branches or pull requests