Node-gyp: Error: %1 is not a valid Win32 application.

Created on 26 Oct 2016  路  11Comments  路  Source: nodejs/node-gyp

Hey,

I have compiled a .node file from a c++ library, the compilation goes just fine but when I try to require it in the js file, It gives the following error.

`Error: %1 is not a valid Win32 application.
\\?\C:\Users\Abc\Desktop\sample_app\2013-12-10\build\Release\hello.node
    at Error (native)
    at Object.Module._extensions..node (module.js:434:18)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at repl:1:9
    at REPLServer.defaultEval (repl.js:262:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)`

Node --version -4.6.1
Python --version - 2.7.12
gyp_msvs_version - 2015

Most helpful comment

I setup full env on Win10 and after a large bunch of build compatibility issues app runs ok for built on Win. Looks like macOS -> Win compilation is not supported (could it even be?)

All 11 comments

It probably means you compiled for the wrong architecture, i.e., your hello.node is 32 bits but node.exe is 64 bits or vice versa.

Hey @bnoordhuis ,

I uninstalled the node 4.6.1 and installed node 6.9.1- 32 bit, did node rebuild and tried to require it. same error

Have you checked that node.exe and hello.node actually match? Try passing --arch ia32 to node-gyp to force a 32-bits build.

Hello @bnoordhuis ,

Yes I tried passing --arch ia32 too, Still the error is the same. How should I match the node.exe and hello.node? On running node-gyp configure gyp info is showing [email protected] | win32 | ia32

Closing due to inactivity. If it's still an issue, let me know and I'll reopen.

My system is different from original in this ticket but an error is essentially the same. I build .node addon on macOS so it's x64 by default. Packaged (with electron-builder) version works fine on macOS (10.13). I run Win10 in Parallels for testing purposes. It's x64 as well. Running win package throws Error: %1 is not a valid Win32 application however.

I setup full env on Win10 and after a large bunch of build compatibility issues app runs ok for built on Win. Looks like macOS -> Win compilation is not supported (could it even be?)

@edudar Looks like we need to have a windows dev machine to compile for windows, kind of problem.

Still an issue. Passing --arch ia32 still passes Platform=x64.

I can't reproduce this issue. When I do:

npm i -g node-gyp
git clone https://github.com/websockets/utf-8-validate
cd utf-8-validate

Using a 64-bit node executable, this works as expected:

node-gyp rebuild --verbose
node -r .\build\Release\validation.node -p process.arch

and this fails as expected:

node-gyp rebuild --arch ia32 --verbose
node -r .\build\Release\validation.node -p process.arch

The log shows Platform=Win32:

gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args   'build/binding.sln',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=Win32'
gyp info spawn args ]

@heaths can you share the output of the commands above for you? Or the output of node-gyp rebuild --arch ia32 --verbose on your project?

Running rebuild --arch ia32 seems to produce the right result. I was running configure --ia32 and build --arch ia32 without success. Perhaps enough artifacts to support incremental builds were left and kept the Platform=x64, but in this case Platform=Win32 was correctly passed. Thanks.

What probably happened initially is that I was using an x64 node, so x64 was defaulted.

Was this page helpful?
0 / 5 - 0 ratings