Default root file (server.js) for node.js site on azure windows

It seems that Windows Azure is expecting your node.js site to work with:

node server.js 

Is there any way to change this command? Specifically, my application root directory is index.js intead server.js , so I would prefer it to do:

 node index.js 

Does anyone know if this is configurable? And even if this is the case, is it usually believed that the bad form has something other than server.js ?

+7
source share
3 answers

What worked for me was the general suggestion above:

In package.json add:

 "scripts": { "start": "node index.js" } 
+13
source

None of the above solutions worked for me. Looking for another thing, I found a solution. You must set your entry point in the web.config file, which is an XML file. Check out this sample file (you just need to replace server.js with what you want):

 <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <handlers> <add name="iisnode" path="server.js" verb="*" modules="iisnode"/> </handlers> <rewrite> <rules> <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true"> <match url="iisnode"/> </rule> <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true"> <match url="^server.js\/debug[\/]?" /> </rule> <rule name="StaticContent"> <action type="Rewrite" url="public{{REQUEST_URI}}"/> </rule> <rule name="DynamicContent"> <conditions> <add input="{{REQUEST_FILENAME}}" matchType="IsFile" negate="True"/> </conditions> <action type="Rewrite" url="server.js"/> </rule> </rules> </rewrite> </system.webServer> </configuration> 
+6
source

Are you asking about Azure websites?

Try to install

 "main": "./index.js" 

in the package.json file.

0
source

All Articles