Azure not using correct version of node - node.js

My project is failing to install in azure. I suspect that Azure is using
the wrong version of node and dying.
My setup:
1) Azure portal, app setting, added WEBSITE_NODE_DEFAULT_VERSION 8.9.1
2) Also, added "engines":{"node": "8.9.3"}, to package.json
When I select console in from Azure portal, development tool:
node -v
D:\home\site\wwwroot
v0.10.40
The kudu page https://purple01.scm.azurewebsites.net/Env.cshtml reports
a path with both the correct and not correct version of node.
Path = D:\Program Files (x86)\SiteExtensions\Kudu\70.10102.3204\bin\NativeBinaries/amd64;D:\home\site\deployments\tools;D:\Program Files (x86)\SiteExtensions\Kudu\70.10102.3204\bin\Scripts;D:\Program Files (x86)\MSBuild\14.0\Bin;D:\Program Files (x86)\Git\cmd;D:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;D:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn;D:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0;D:\Program Files (x86)\Git\bin;D:\Program Files (x86)\Git\usr\bin;D:\Program Files (x86)\Git\mingw32\bin;D:\Program Files (x86)\nodejs\0.10.28;D:\Program Files (x86)\npm\1.4.28;C:\DWASFiles\Sites#1purple01\AppData\npm;D:\Program Files (x86)\bower\1.7.9;D:\Program Files (x86)\grunt\0.1.13;D:\Program Files (x86)\gulp\3.9.0.1;D:\Program Files (x86)\funcpack\0.2.2;D:\Program Files (x86)\nodejs\8.9.1;D:\Windows\system32;D:\Windows;D:\Windows\System32\Wbem;D:\Windows\System32\WindowsPowerShell\v1.0\;D:\Program Files (x86)\Git\cmd;D:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;;D:\Program Files (x86)\dotnet;D:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;D:\Program Files (x86)\PHP\v5.6;D:\Python27;
The only error reported is in a file found on
ftp://waws-prod-sn1-053.ftp.azurewebsites.windows.net/LogFiles/Application/logging-errors.txt
Sat Jan 13 2018 00:53:57 GMT+0000 (Coordinated Universal Time): Application has thrown an uncaught exception and is terminated:
SyntaxError: Use of const in strict mode.
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 (x86)\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)
Sat Jan 13 2018 02:17:45 GMT+0000 (Coordinated Universal Time): Application has thrown an uncaught exception and is terminated:
SyntaxError: Use of const in strict mode.
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)
Not sure if this error is my code failing or Azure code failing. My code does use strict and a bunch of new stuff like promises. So I need a current version of node.
Any suggestions as to what is wrong with the Azure setup?

There is no Node 8.9.1 installed on App Service so it defaults to whatever the default is (apparently 0.10.40).
You can see a list of available (installed) Node engines here -
https://{sitename}.scm.azurewebsites.net/api/diagnostics/runtime
Change WEBSITE_NODE_DEFAULT_VERSION to read 8.9.3 and you should be good.
Test with node -v in Kudu:
By the way, you can look at the log stream here, no need to throw FTP at the problem -
https://{sitename}.scm.azurewebsites.net/api/logstream
There's also a Log Stream blade under your Web App in the Azure Portal that connects to the same endpoint:

Related

(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.

NodeJS 8.10.0 - Azure (iisnode) - Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

I'm hosting a NodeJs web app in Microsoft Azure, and I'm receiving the following error:
Sun Mar 25 2018 01:32:14 GMT+0000 (Coordinated Universal Time): Application has thrown an uncaught exception and is terminated: SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
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 Object.<anonymous> (D:\home\site\wwwroot\server\helpers\email.js:1:77)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
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 Object.<anonymous> (D:\home\site\wwwroot\server\controllers\email.js:2:13)
at Module._compile (module.js:409:26)
at the error line:
var Mailgun = require('mailgun-js');
The same application is working properly in another Azure Web App (same config between the two).
To setup the NodeJs version I'm using across all the web apps the WEBSITE_NODE_DEFAULT_VERSION application setting.
I would expect this kind of error with older versions of nodejs, but not with the 8.10.
Any idea?
I just found that the web application with problems was created using a Microsoft template "Node JS Empty Web App".
This template left on the root of the web application the iisnode.yml file that was forcing the version 4.2.4, despite globally was used the 8.10.0.
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\4.2.4\node.exe"
Removing the iisnode.yml solved the issue.
As mentioned by redeyes.
another approach is to edit the path with the version number
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\8.10.x\node.exe"

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

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.

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/

How to use node-oracle with iisnode?

I'm having trouble trying to run a Node.js server with node-oracle via iisnode. The iisnode examples all work, and running the server [on a different port] in a Command Window works perfectly. The server setup is based upon "The Node Beginner Book" example (i.e. index.njs -> server.njs -> router.njs -> requesthandlers.njs). I renamed all of my node files as *.njs and currently have my web.config set up for iisnode to handle all files of that extension, with a rewrite rule to forward the incoming requests to index.njs. The problem occurs when node-oracle -- utilized within requesthandlers.njs -- attempts to call oracle_bindings.node:
Application has thrown an uncaught exception and is terminated:
Error: The specified module could not be found.
c:\Program Files\iisnode\www\Reports\node_modules\oracle\build\Release\oracle_bindings.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> (c:\Program Files\iisnode\www\Reports\node_modules\oracle\lib\oracle.njs:2:16)
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 given read/write/execute permissions to the IIS_IUSRS group on every folder imaginable within the .\iisnode\www\Reports\node_modules\oracle path. I've also attempted the solution in Node cannot find modules in IIS, can find from prompt to no avail. While I could probably just set the server up as a service, I'd prefer to have it through IIS so that I don't have to battle with CORS while supporting IE9. Any help is greatly appreciated, thanks!

Resources