Azure NodeJS 'Error: %1 is not a valid Win32 application.' - node.js

I am trying to make a NodeJS App service using Azure. However, it appears the node module -nodehun- I am trying to use is interfering with the compilation process.
See error:
\\?\D:\home\site\wwwroot\node_modules\nodehun\build\Release\nodehun.node
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\home\site\wwwroot\server.js:6:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
Wed Sep 20 2017 16:18:27 GMT+0000 (Coordinated Universal Time): Application has thrown an uncaught exception and is terminated:
Error: %1 is not a valid Win32 application.
After a bit of searching, this can be caused by a mismatch between 32/64bit architecture of node.exe and the built module. Although, I'm not sure how to fix this problem within Azure.

According to the error message you got, it seems that nodehun requires 64bit node.js runtime. By default, Azure App Service does not have 64bit node.exe installed. The workaround for what you want to do would be place 64 bit node.exe in d:\home\site\wwwroot\runtime and then create a iisnode.yml with the following content:
nodeProcessCommandLine: "D:\home\site\wwwroot\runtime\node.exe"
After that done, don't forget to restart your App Service. More details, please refer to bcrypt not a valid win 32 application on azure app service.

Thanks to Aaron Chen for pointing me in the right direction.
In the Azure web app, there is a Web.config file. Within this file there is an iisnode section, which I added the nodeProcessCommandLine to, e.g:
<iisnode watchedFiles="web.config;*.js" nodeProcessCommandLine="D:\home\site\wwwroot\runtime\node.exe"/>
This fixes the above error and runs node as 64bit, provided a 64bit version of node is supplied.

Related

Issues with Sharp in Azure functions

Hi I have been trying to deploy my code for resizing image streams in azure function.
It seems to be working perfectly fine in local, even deployment via VS code is successful.
But when I try to trigger the function, I get below exception.
Relatively new to both nodejs and azure, any suggestions?
2021-06-08T04:51:24.370 [Information] Executing 'Functions.HttpTrigger1' (Reason='This function was programmatically called via the host APIs.', Id=7bd3aba0-8833-4ffe-b2c7-a061533fef6a)
2021-06-08T04:51:24.444 [Error] Executed 'Functions.HttpTrigger1' (Failed, Id=7bd3aba0-8833-4ffe-b2c7-a061533fef6a, Duration=17ms)
Result: Failure
Exception: Worker was unable to load function HttpTrigger1: 'Error: 'win32-x64' binaries cannot be used on the 'win32-ia32' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'win32-ia32' platform.'
Stack: Error: 'win32-x64' binaries cannot be used on the 'win32-ia32' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'win32-ia32' platform.
at Object.hasVendoredLibvips (C:\home\site\wwwroot\node_modules\sharp\lib\libvips.js:82:13)
at Object.<anonymous> (C:\home\site\wwwroot\node_modules\sharp\lib\constructor.js:7:22)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\home\site\wwwroot\node_modules\sharp\lib\index.js:3:15)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
According to the error message, we need to update Azure function as 64 bit Platform. Regarding how to do that, please refer to here.

(update solution)Express web app service is throwing "SyntaxError: Unexpected token >"

I deployed the same web app to two Azure app services, one the fine, while another is throwing such an error. My web is based on Express, how could I fix this issue? Looks the error is not from my source code.
Fri Jul 27 2018 20:05:22 GMT+0000 (Coordinated Universal Time): Application has thrown an uncaught exception and is terminated:
SyntaxError: Unexpected token >
at Module._compile (module.js:434:25)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Module.require (module.js:359:17)
at require (module.js:375:17)
at Object.<anonymous> (D:\Program Files\iisnode\interceptor.js:459:1)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
I came across this issue when I set WEBSITE_NODE_DEFAULT_VERSION to a version that was not compatible with Azure.
It fell back to a really old version of node that does not support arrow functions.
You can verify this by going to the Azure Console and doing node -v
This issue was fixed finally, we raised a ticket to MS, Microsoft redeployed the app service to a new set of servers.Then the web site works.

Using Node v4.0 for Windows Azure Web App

I am building a web app using Node. I started when version 4.0 of Node came out. When I run node -v on my local machine, I see: "v4.0.0". I deployed the site as a Microsoft Azure Web App. However, that introduced a 500 error.
I looked at the logs, and I see the following:
Wed Sep 23 2015 13:29:20 GMT+0000 (Coordinated Universal Time): Unaught exception: SyntaxError: Unexpected reserved word
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (D:\home\site\wwwroot\routes\index.js:4:11)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
The line in question uses the class keyword, which is allowed in Node 4.0. That prompted me to check the version of node running in my Azure Web App. From the console in Azure, I ran, node -v again. Now I see, "v0.10.32".
How do I get Node 4.0 running for a Microsoft Azure Web App?
specify the version in your "engines" directive in package.json
{
"engines":{"node":4.0.0}
}
more info about specifying versions here: https://azure.microsoft.com/en-us/documentation/articles/nodejs-specify-node-version-azure-apps/

Use edge js on openshift

I'm trying to run C# on my OpenShift cartridge with Edge.js. It runs really good on my Windows PC and I would like to have it running on the cloud.
I'm guessing it runs on a Linux environment but I'm not shure.
At first I tried to make it work with my MSSQL DB and than move on to the C# assembly.
Nevertheless I'm doing the same steps as how I've got it to work on my Windows machine but I'm getting thesame errors over and over again.
I've added edge and edge-sql to my npm and my package.json.
Then I've make a simple count to my MSSQL DB.
When I'm running it locally it works great. Than I push it to OpenShift and I tail the application, because the front-end gives me an Error 503, and the next thing I know the following error makes me keepings my hands in my hair.
Error: The edge native module is not available at /var/lib/openshift/54d26260fcf
933d05e00021a/app-root/runtime/repo/node_modules/edge/build/Release/edge.node. Y
ou can use EDGE_NATIVE environment variable to provide alternate location of edg
e.node. If you need to build edge.node, follow build instructions for your platf
orm at https://github.com/tjanczuk/edge
at Object.<anonymous> (/var/lib/openshift/54d26260fcf933d05e00021a/app-root/
runtime/repo/node_modules/edge/lib/edge.js:33:11)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/lib/openshift/54d26260fcf933d05e00021a/app-root/
runtime/repo/server.js:5:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
DEBUG: Program node server.js exited with code 8
DEBUG: Starting child process with 'node server.js'
/var/lib/openshift/54d26260fcf933d05e00021a/app-root/runtime/repo/node_modules/e
dge/lib/edge.js:33
throw new Error('The edge native module is not available at ' + builtEdge
Could somebody help me to fix this error or maybe explain to me why it could / wont work?
If edge requires a native windows environment to run C#, then it will not work on OpenShift, which runs on Red Hat Linux.

Invalid Win32 application while using iisnode, nodejs and node-soap library

I'm having some issues setting up a Node.js/Node-soap service running on IIS 7, Windows Server 2008, with iisnode and node.js 0.10.20. This same setup, with the same code, is running on another server inhouse and works perfectly.
The problem is that the setup process wasn't documented, and the person that put it all up is not available to migrate it to the new server. And I have no prior knowledge in Node nor IISnode.
This is the error message that gets printed:
iisnode encountered an error when processing the request.
HRESULT: 0x2 HTTP status: 500 HTTP reason: Internal Server Error You
are receiving this HTTP 200 response because
system.webServer/iisnode/#devErrorsEnabled configuration setting is
'true'.
In addition to the log of stdout and stderr of the node.exe process,
consider using debugging and ETW traces to further diagnose the
problem.
The last 64k of the output generated by the node.exe process to stderr
is shown below:
Application has thrown an uncaught exception and is terminated: Error:
%1 is not a valid Win32 application.
\node_modules\soap\node_modules\node-expat\build\Release\node_expat.node
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (<Path to application>\node_modules\soap\node_modules\node-expat\lib\node-expat.js:4:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
I've added the following to my Node.js file:
Now what I have found online, tried but hasn't worked, is as follows:
From this Stack Overflow question I tried two things:
Added this part to my Node.js file.
<iisnode watchedFiles="*.js;node_modules\*;routes\*.js;views\*.jade" nodeProcessCommandLine="\program files\nodejs\node.exe"/>
Created a symbolic link:
mklink /D "C:\Program Files (x86)\nodejs" "C:\Program Files\nodejs"
Will update if I try something else.
All help would be appreciated.
UPDATE 1:
I've made sure that the Enable32-Bit Applications = False. is set in IIS, and repaired the VS 2010 x64 redist binary
This error message suggests the bitness of \node_modules\soap\node_modules\node-expat\build\Release\node_expat.node does not match the bitness of the IIS worker process (w3wp.exe). Since you appear to be running IIS with 64 bit worker processes (Enable 32-bit Applications == False), it may indicate that node_expat.node is a 32-bit binary?

Resources