nodejs applicaiton giving error "%1 is not a valid Win32 application" in windows machine

Praful picture Praful · Oct 30, 2015 · Viewed 9.8k times · Source

My Nodejs application works fine in ubuntu. When i tried to deploy the same in Windows machine it showed below error.

=>node server.js  
D:\home\site\wwwroot
D:\home\site\wwwroot\node_modules\ffi\node_modules\bindings\bindings.js:83
        throw e                  ^
Error: %1 is not a valid Win32 application.   
D:\home\site\wwwroot\node_modules\ffi\node_modules\ref\build\Release\binding.node
    at Error (native)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at bindings 

I removed ffi module and tried npm install ffi again in windows machine it too didnt work.

 => npm install ffi
D:\home\site\wwwroot
npm WARN package.json @ No description
npm WARN package.json @ No repository field.
npm WARN package.json @ No README data
npm WARN package.json @ No license field.
gyp ERR! build error 
gyp ERR! stack Error: `msbuild` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (c:\Program Files (x86)\npm\2.11.2\node_modules\npm\node_modules\node-gyp\lib\build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "c:\\Program Files (x86)\\npm\\2.11.2\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\home\site\wwwroot\node_modules\ffi
gyp ERR! node -v v0.12.6
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok 
npm ERR! Windows_NT 6.2.9200

Could you please provide your thought on this issue

Answer

mscdex picture mscdex · Oct 30, 2015

You can't move compiled addons across different platforms like that (much like you can't copy a Linux executable to Windows and expect to be able to execute it). You will need to npm rebuild in your project directory to recompile any addons after you copy your project tree to a different platform.