Node 0.11.x in Azure Web Site

喜你入骨 提交于 2019-12-11 20:36:40

问题


I am trying to get a node app running on Azure with version 0.11.x of node, so I can take advantage of some new features (e.g. generators & Koa).

I have read this question and tried to follow the steps, with no success so far:

Error setting up node v0.11.x on Azure WebSite

Here are the steps I did:

  1. In VS2013 (update3), File => New Project Choose "Blank Microsoft Azure Node.js Web Application" (under Templates/Javascript/node.js), click OK

  2. In server.js, change the last "hello world" line to show the node version:

    res.end('App running in node version ' + process.version + '\n');

  3. Add a new file "iisnode.yml" in same folder as server.js, with the contents:

    nodeProcessCommandLine: D:\home\site\wwwroot\bin\node.exe

  4. Copy node.exe (version 0.11.13) into the "bin" folder (under the folder where server.js is)

  5. Right-click the project in VS, select Publish, create new Website with all the default credentials/etc... then click Publish

At this point, the "myproj.azurewebsites.net" page comes up with the response:

App running in node version v0.10.29

But I was hoping for node version 0.11.13. If I go to my \bin folder and run node.exe --version it spits out:

v0.11.13

Running locally (F5) seems to do the right thing: App running in node version v0.11.13

I'm fairly stumped how to get node 0.11 running on an Azure web site, any suggestions?


回答1:


The following works for me: I have node.exe in d:\home\site\wwwroot and I have the following in my web.config:

<configuration>
   <system.webServer>
     <handlers>
       <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
     </handlers>
     <iisnode nodeProcessCommandLine="d:\home\site\wwwroot\node.exe" />
   </system.webServer>
</configuration>




回答2:


Well I found a workaround to the problem, hopefully this saves someone else some time.

It looks like the problem is that the IISNODE.YML file needs to be ANSI encoded. When I created the file from Visual Studio 2013, it chose UTF8 as the default encoding for the file.

To correct the problem, save the file with ANSI encoding. For eample, you can do this by open the file in notepad, then doing Save As... and pick the Encoding as ANSI.

I looked briefly at the source code for "iisnode" and it appears that the problem is in this code:

CModuleConfiguration::ApplyYamlConfigOverrides

although I didn't have time to test it yet.



来源:https://stackoverflow.com/questions/25410810/node-0-11-x-in-azure-web-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!