Skip to content
This repository has been archived by the owner on Jun 8, 2020. It is now read-only.

Attempt to make this work with nwjs 0.13.3 #6

Closed
VRastrigin opened this issue Apr 6, 2016 · 18 comments
Closed

Attempt to make this work with nwjs 0.13.3 #6

VRastrigin opened this issue Apr 6, 2016 · 18 comments

Comments

@VRastrigin
Copy link

My configuration:

  • Win7 x64
  • Visual Studio 2013
  • Python 2.7.3
  • Node.JS 4.4.2 (built-in npm 3.8.5)
  • nw-gyp 0.13.0 (npm install -g nw-gyp)
  • nw.js 0.13.3 , sdk version, x64
  • edge.js 5.0.0
  • Node.js command prompt
  1. I use as instruction this example for nwjs 0.12.0: https://github.com/frankhale/nw-edge-example, (it uses edge.js 0.10.1) and works perfectrly fine;
  2. but when i try to get work the same with nwjs 0.13.3 and edge.js 5.0.0, i get this error in the nw.js debugger:
    ...\TestApp_new_nwjs-sdk-v0.13.3-win-x64\TestApp\node_modules\edge\lib\edge.js:79 Uncaught TypeError: Cannot read property 'getFileName' of undefinedexports.func @
    ...\TestApp_new_nwjs-sdk-v0.13.3-win-x64\TestApp\node_modules\edge\lib\edge.js:79

79th string of edge.js looks like:
" options = { source: options, jsFileName: stack[1].getFileName(), jsLineNumber: stack[1].getLineNumber() }; "

What i change from instruction:

  1. target version, which i give to nw-gyp:
    "nw-gyp configure --target=v0.13.3 --msvs_version=2013"
  2. after building edge, it gives two files: "edge_coreclr.node" and "edge_nativeclr.node" instaed of one "edge.node" in previous versions of edge, so
    i create new dir ...\TestApp_new_nwjs-sdk-v0.13.3-win-x64\TestApp\node_modules\edge\lib\native\win32\x64\4.4.2
    (because i have node.js 4.4.2)
    and copy these files there
  3. i edit edge.js versionmapping:
    ...\TestApp_new_nwjs-sdk-v0.13.3-win-x64\TestApp\node_modules\edge\lib\edge.js:
    [ /^0.8./, '0.8.22' ],
    [ /^0.10./, '0.10.0' ],
    [ /^0.12./, '0.12.0' ],
    [ /^4./, '4.1.1' ],
    [ /^4.4.2/, '4.4.2' ], // i add this row
    [ /^5./, '5.1.0' ],
    Any suggestions?
@frankhale
Copy link
Owner

Thanks for the report. It's been a while since I've updated this so I'll give it a shot as soon as I can to see if I can get it working with latest version of NW.js.

@WinterWoods
Copy link

I also need nwjs 0.13 5.0.0 edge, and I want to finish the job myself.
Now I suggest

Uncaught Error: %1 is not a valid Win32 application. \\?\D:\work\客户端标准\Clients\nwjs-sdk-v0.13.3-win-x64\node_modules\edge\lib\native\win32\x64\5.1.0\edge_nativeclr.node

@frankhale
Copy link
Owner

@longang520, the error you report is normally because the compiled native module is not able to be loaded into the version of NWjs that you have. Could be mismatched 32bit / 64bit or something else. I have not tried with latest NWjs yet so don't know what changes will need to take place in order to make it work (yet).

@VRastrigin
Copy link
Author

@longang520 I was able to reproduce your error with nwjs-sdk-v0.13.3-win-ia32, to get rid of it I rebuild edge as x86 (which, i assume, by default is being downloaded as x64 version):

  1. I put my app dir in c:\nwjs-sdk-v0.13.3-win-ia32\testapp
  2. I open node.js command prompt and run following commands:
    cd c:\nwjs-skd-v0.13.3-win-ia32\testapp
    npm install edge
    cd node_module
    cd edge
    nw-gyp configure --target=v0.13.3 --msvs_version=2013 --arch=ia32
    nw-gyp build
  3. I copy all files from c:\nwjs-sdk-v0.13.3-win-ia32\testapp\node_modules\edge\build\Release to c:\nwjs-sdk-v0.13.3-win-ia32\testapp\node_modules\edge\lib\native\win32\ia32\5.1.0

I think that you could do the same, but only:

  • to configure edge's build you should slightly change the command:

nw-gyp configure --target=v0.13.3 --msvs_version=2013 --arch=x64

  • copy all files to C:\desktopapp\new_\nwjs-sdk-v0.13.3-win-x64\testapp\node_modules\edge\lib\native\win32\x64\5.1.0

P.S.:and after that i'm back to my main problem with "property 'getFileName' ").

@WinterWoods
Copy link

@VRastrigin
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | ia32
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at failNoPython (C:\Users\east\AppData\Roaming\npm\node_modules\nw-gyp\lib\configure.js:102:14)
gyp ERR! stack at C:\Users\east\AppData\Roaming\npm\node_modules\nw-gyp\lib\configure.js:65:11
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 10.0.14295
gyp ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Users\east\AppData\Roaming\npm\node_modules\nw-g
yp\bin\nw-gyp.js" "configure" "--target=v0.13.3" "--msvs_version=2013" "--arch=ia32"
gyp ERR! cwd C:\nwjs-sdk-v0.13.3-win-x64\testapp\node_modules\edge
gyp ERR! node -v v5.10.1
gyp ERR! nw-gyp -v v0.13.0
gyp ERR! not ok

@WinterWoods
Copy link

@VRastrigin
C:\nwjs-sdk-v0.13.3-win-x64\testapp\node_modules\edge>nw-gyp configure --target=v0.13.3 --msvs_version=2013 --arch=ia32
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | ia32
gyp http GET http://node-webkit.s3.amazonaws.com/v0.13.3/nw-headers-v0.13.3.tar.gz
gyp http 404 http://node-webkit.s3.amazonaws.com/v0.13.3/nw-headers-v0.13.3.tar.gz
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: 404 status code downloading tarball
gyp ERR! stack at Request. (C:\Users\east\AppData\Roaming\npm\node_modules\nw-gyp\lib\install.js:236:14)
gyp ERR! stack at emitOne (events.js:95:20)
gyp ERR! stack at Request.emit (events.js:182:7)
gyp ERR! stack at Request.onRequestResponse (C:\Users\east\AppData\Roaming\npm\node_modules\nw-gyp\node_modules\requ
est\request.js:957:10)
gyp ERR! stack at emitOne (events.js:90:13)
gyp ERR! stack at ClientRequest.emit (events.js:182:7)
gyp ERR! stack at HTTPParser.parserOnIncomingClient (_http_client.js:469:21)
gyp ERR! stack at HTTPParser.parserOnHeadersComplete (_http_common.js:103:23)
gyp ERR! stack at Socket.socketOnData (_http_client.js:359:20)
gyp ERR! stack at emitOne (events.js:90:13)
gyp ERR! System Windows_NT 10.0.14295
gyp ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Users\east\AppData\Roaming\npm\node_modules\nw-g
yp\bin\nw-gyp.js" "configure" "--target=v0.13.3" "--msvs_version=2013" "--arch=ia32"
gyp ERR! cwd C:\nwjs-sdk-v0.13.3-win-x64\testapp\node_modules\edge
gyp ERR! node -v v5.10.1
gyp ERR! nw-gyp -v v0.13.0
gyp ERR! not ok

@WinterWoods
Copy link

@VRastrigin
C:\nwjs-sdk-v0.13.3-win-x64\testapp\node_modules\edge>nw-gyp build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | ia32
(node) child_process: options.customFds option is deprecated. Use options.stdio instead.
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=Win32' ]
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: The build
ools for v120 (Platform Toolset = 'v120') cannot be found. To build using the v120 build tools, please install v120 bu
ld tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-cl
ck the solution, and then selecting "Retarget solution". [C:\nwjs-sdk-v0.13.3-win-x64\testapp\node_modules\edge\build
dge_nativeclr.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: The build
ools for v120 (Platform Toolset = 'v120') cannot be found. To build using the v120 build tools, please install v120 bu
ld tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-cl
ck the solution, and then selecting "Retarget solution". [C:\nwjs-sdk-v0.13.3-win-x64\testapp\node_modules\edge\build
dge_coreclr.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:\Users\east\AppData\Roaming\npm\node_modules\nw-gyp\lib\build.js:286:23)
gyp ERR! stack at emitTwo (events.js:100:13)
gyp ERR! stack at ChildProcess.emit (events.js:185:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Windows_NT 10.0.14295
gyp ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Users\east\AppData\Roaming\npm\node_modules\nw
yp\bin\nw-gyp.js" "build"
gyp ERR! cwd C:\nwjs-sdk-v0.13.3-win-x64\testapp\node_modules\edge
gyp ERR! node -v v5.10.1
gyp ERR! nw-gyp -v v0.13.0
gyp ERR! not ok

@VRastrigin
Copy link
Author

@longang520

I'd also checked if there are installed (they, who use nw.js usually recommend it), and if not, install:

  • Microsoft Visual C++ 2013 redistributable x86
  • Microsoft Visual C++ 2013 redistributable x64
  • Windows 7.1 SDK
  1. "gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable."
    this means that either you didn't install Python, or you didnt reboot after installing (because environment variables sets only after reboot).
  2. "The build tools for v120 (Platform Toolset = 'v120') cannot be found. To build using the v120 build tools, please install v120 build tools." this maybe means that you didnt install "MS Visual C++ 2013"[http://stackoverflow.com/a/19804847]
  3. If neither of this would help, you could try to open
    C:\desktopapp\new_\nwjs-sdk-v0.13.3-win-x64\testapp\node_modules\edge\build\binding.sln in Visual Studio 2013, rebuild it from studio in the next order: 1) edge_coreclr 2) edge_nativeclr 3) rebuild whole solution (because it may show errors on first-second time), copy output files to "lib" directory like you did it before and then try to execute your app. Does it work?
    P.S.: which command prompt do you use? Windows cmd, Windows SDK 7.1 Command Prompt, Visual Studio Command Prompt or Node.js Command Prompt?

@WinterWoods
Copy link

@VRastrigin
Thank you, I have compiled the success, and work. Thank you very much.

@VRastrigin
Copy link
Author

@longang520 no problem, so it's very interesting to me if your NW.JS+edge.js compiled example shows you your c# string?
(because mine is not and i always get this error of missing property "getFileName()")

@frankhale
Copy link
Owner

I'm going to play with this today.

I did notice on the NWjs documentation this:

http://docs.nwjs.io/en/latest/For%20Users/Advanced/Use%20Native%20Node%20Modules/

Starting from 0.13.0, native modules built by node-gyp or npm in upstream can be supported.

In Linux and OSX you can just load the native module directly. In windows you’ll need to replace the file
%APPDATA%\npm\node_modules\node-gyp\src\win_delay_load_hook.c with the one at https://github.com/nwjs/nw.js/blob/nw13/tools/win_delay_load_hook.c

@longang520, I see your comment about that you got it to compile and work. Are you saying that the example is totally working for you in the latest version of NWjs?

@WinterWoods
Copy link

Yes, the latest version of 0.13.3 nwjs, do you need an example?

@frankhale
Copy link
Owner

I'd love to know the steps you used to build the module. The documentation link I just pasted above is a bit misleading and it says that nw-gyp is no longer needed for native modules but they go on to mention how to build modules still using nw-gyp. I am currently trying to get it to work without using nw-gyp but have not succeeded yet.

@WinterWoods
Copy link

  1. I put my app dir in c:\nwjs-sdk-v0.13.3-win-ia32\testapp
  2. I open node.js command prompt and run following commands:
    cd c:\nwjs-skd-v0.13.3-win-ia32\testapp
    npm install edge
    cd node_module
    cd edge
    nw-gyp configure --target=v0.13.3 --msvs_version=2013 --arch=ia32
    nw-gyp build
  3. I copy all files from c:\nwjs-sdk-v0.13.3-win-ia32\testapp\node_modules\edge\build\Release to c:\nwjs-sdk-v0.13.3-win-ia32\testapp\node_modules\edge\lib\native\win32\ia32\5.1.0

Your step is not successful, send out your problem, I can help solve

@VRastrigin
Copy link
Author

@longang520 i confirm, mine works too: nw.js 0.13.3 x86 + edge 5.0.0 x86

@frankhale
Copy link
Owner

Trying this now. Thanks!

@frankhale
Copy link
Owner

Yeah it all works. Thanks for mentioning your steps. I substituted 32bit for 64 in my case and still works fine. I appreciate your help. I'll update the README.

@frankhale
Copy link
Owner

README has been updated via 3afb188

THANK YOU FOR YOUR HELP!!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants