【发布时间】:2019-04-16 01:19:44
【问题描述】:
我正在尝试从模板创建 web 应用程序。这个问题是,当我运行应用程序时,我收到“由于发生内部服务器错误,无法显示页面”。我做了一些研究,似乎我的节点安装有问题。
我已经尝试重新安装 npm,当前版本是 1.4.28。错误日志显示:
0 信息如果它以 ok 结尾,它就会起作用 1个详细的cli ['节点', 1 详细的 cli 'D:\Program Files (x86)\npm\1.4.28\node_modules\npm\bin\npm-cli.js', 1 详细的 cli 'init' ] 2 使用 npm@1.4.28 的信息 3 使用 node@v0.10.40 的信息 4 错误 错误:EINVAL,无效参数 新 Socket 的 4 错误 (net.js:157:18) process.stdin (node.js:693:19) 出现 4 错误 4 读取错误(D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\read\lib\read.js:18:36) PromZard.prompt 出现 4 错误(D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\init-package-json\node_modules\promzard\promzard.js:214:3) PromZard.L 出现 4 错误(D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\init-package-json\node_modules\promzard\promzard.js:177:21) PromZard.walk 出现 4 错误(D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\init-package-json\node_modules\promzard\promzard.js:146:5) PromZard.loaded 4 错误 (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\init-package-json\node_modules\promzard\promzard.js:90:8) PromZard 出现 4 个错误。 (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\init-package-json\node_modules\promzard\promzard.js:57:10) fs.js:272:14 处出现 4 个错误 Object.oncomplete (fs.js:108:15) 出现 4 个错误 5 错误如果您需要帮助,您可以报告此整个日志, 5 错误,包括 npm 和节点版本,位于: 5 错误http://github.com/npm/npm/issues 6 错误系统 Windows_NT 6.2.9200 7 错误命令 "node" "D:\Program Files (x86)\npm\1.4.28\node_modules\npm\bin\npm-cli.js" "init" 8 错误 cwd D:\home\site\wwwroot 9 错误节点-v v0.10.40 10 错误 npm -v 1.4.28 11 错误系统调用 uv_pipe_open 12 错误代码 EINVAL 13 错误错误号 18 14 详细退出 [ 18, true ]
这是我所拥有的:
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')
});
服务器.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);
我最初是从 server.js 获得结果,但我进行了一些更改以尝试解决问题以及我如何一无所获。有人能指出我的问题吗?
谢谢
编辑:添加 zip 会执行此操作,创建另一个级别的文件夹,我收到消息“您无权查看此目录或页面。”当我尝试运行应用程序时。
【问题讨论】:
-
你指的是哪个模板?
-
github.com/jay3dec/NodeTaskApp 完整教程位于codehandbook.org/web-app-using-node-js-and-mysql,但我永远无法让 step run node app.js 工作,所以我认为我遇到了问题。
-
错误出现在您的本地环境中,对吧?
-
我在 azure 中运行整个程序,而不是在本地运行。 portal.azure.com
-
你在本地试过吗?