Reputation: 349
I am trying to create a webapp from a template. This issue is that when I run the app, I am getting 'The page cannot be displayed because an internal server error has occurred'. I have done a bit of research and seem to be having issues with my node installation.
I have tried reinstalling npm, current version is 1.4.28. The error log shows:
0 info it worked if it ends with ok 1 verbose cli [ 'node', 1 verbose cli 'D:\Program Files (x86)\npm\1.4.28\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'init' ] 2 info using [email protected] 3 info using [email protected] 4 error Error: EINVAL, invalid argument 4 error at new Socket (net.js:157:18) 4 error at process.stdin (node.js:693:19) 4 error at read (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\read\lib\read.js:18:36) 4 error at PromZard.prompt (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\init-package-json\node_modules\promzard\promzard.js:214:3) 4 error at PromZard.L (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\init-package-json\node_modules\promzard\promzard.js:177:21) 4 error at PromZard.walk (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\init-package-json\node_modules\promzard\promzard.js:146:5) 4 error at PromZard.loaded (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\init-package-json\node_modules\promzard\promzard.js:90:8) 4 error at PromZard. (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\init-package-json\node_modules\promzard\promzard.js:57:10) 4 error at fs.js:272:14 4 error at Object.oncomplete (fs.js:108:15) 5 error If you need help, you may report this entire log, 5 error including the npm and node versions, at: 5 error http://github.com/npm/npm/issues 6 error System Windows_NT 6.2.9200 7 error command "node" "D:\Program Files (x86)\npm\1.4.28\node_modules\npm\bin\npm-cli.js" "init" 8 error cwd D:\home\site\wwwroot 9 error node -v v0.10.40 10 error npm -v 1.4.28 11 error syscall uv_pipe_open 12 error code EINVAL 13 error errno 18 14 verbose exit [ 18, true ]
Here's what I have:
Web.config
<configuration>
<system.webServer>
<handlers>
<!-- indicates that the app.js file is a node.js application to be handled by the iisnode module -->
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<!-- Don't interfere with requests for logs -->
<rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$" />
</rule>
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^app.js\/debug[\/]?" />
</rule>
<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}" />
</rule>
<!-- All other URLs are mapped to the Node.js application entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
</conditions>
<action type="Rewrite" url="app.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
App.js
var express = require('express');
var app = express();
app.use('/node_modules', express.static(__dirname + '/node_modules'));
app.use('/style', express.static(__dirname + '/style'));
app.use('/script', express.static(__dirname + '/script'));
app.get('/',function(req,res){
res.sendFile('home.html',{'root': __dirname + '/templates'});
})
app.get('/showSignInPage',function(req,res){
res.sendFile('signin.html',{'root': __dirname + '/templates'});
})
app.get('/showSignUpPage',function(req,res){
res.sendFile('signup.html',{'root':__dirname + '/templates'})
})
app.listen(3000,function(){
console.log('Node server running @ http://localhost:3000')
});
Server.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end('Hello, world!');
}).listen(process.env.PORT || 8080);
I was initially getting the results from the server.js, but I have made a few changes to try and resolve the issue and how I am getting nothing. Is anyone able to pinpoint me to the issue?
Thanks
Edit: Adding the zip does this, creating another level of folder, and I am getting the message 'You do not have permission to view this directory or page.' when I try to run the app.
Upvotes: 1
Views: 332
Reputation: 15629
You need to change
app.listen(3000,function(){
console.log('Node server running @ http://localhost:3000')
});
to app.listen(process.env.PORT);
The only way an azure webapp can be accessed via the internet is through the already-exposed HTTP (80) and HTTPS (443) TCP ports;
I have tested the project with your web.config and app.js. I will encounter the same error as yours.
After changing the listen port, it works well. You can refer to this article to deploy your nodejs app to azure.
Upvotes: 2