Node.js Azure NodeJS错误:enoint,open';D:\home\site\wwwroot\bin\views\&x27;
我一直在尝试将节点应用程序部署到Azure,但遇到了问题。我想我知道问题的根源,但不确定如何更改配置来修复它 出于某种原因,我的节点进程希望使用D:\home\site\wwwroot\bin作为查找脚本文件和视图的路径,而不是查看D:\home\site\wwwroot 我得到错误:error:enoint,打开'D:\home\site\wwwroot\bin\views\layouts\layout.hbs' 在stacktrace上,这意味着正在调用my app.js,但它在错误的位置查找视图 我如何告诉azure再上一个目录以查找布局,而不是使用bin作为默认设置?附件是我的虚拟机上站点的目录结构 /siteNode.js Azure NodeJS错误:enoint,open';D:\home\site\wwwroot\bin\views\&x27;,node.js,azure,Node.js,Azure,我一直在尝试将节点应用程序部署到Azure,但遇到了问题。我想我知道问题的根源,但不确定如何更改配置来修复它 出于某种原因,我的节点进程希望使用D:\home\site\wwwroot\bin作为查找脚本文件和视图的路径,而不是查看D:\home\site\wwwroot 我得到错误:error:enoint,打开'D:\home\site\wwwroot\bin\views\layouts\layout.hbs' 在stacktrace上,这意味着正在调用my app.js,但它在错误的位置查
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2/9/2015 6:27 PM bin
d---- 2/9/2015 6:27 PM controllers
d---- 2/9/2015 6:27 PM models
d---- 2/9/2015 6:27 PM node_modules
d---- 2/9/2015 6:27 PM public
d---- 2/9/2015 6:28 PM tests
d---- 2/9/2015 6:28 PM views
-a--- 2/9/2015 6:38 PM 2448 app.js
-a--- 2/7/2015 1:17 AM 634 config.js
-a--- 2/9/2015 6:25 PM 202392 hostingstart.html
-a--- 2/7/2015 1:40 AM 597 package.json
-a--- 2/5/2015 9:37 PM 22 README.md
-a--- 2/7/2015 1:18 AM 1236 routes.js
-a--- 2/7/2015 1:49 AM 1801 Web.config
-a--- 2/5/2015 9:37 PM 1671 Web.Debug.config
站点/bin
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 10/21/2014 11:29 PM 629 ChangeConfig.ps1
-a--- 10/21/2014 11:29 PM 2141 download.ps1
-a--- 1/10/2015 12:46 AM 24256 Microsoft.NodejsTools.WebRole.dll
-a--- 10/21/2014 11:29 PM 17 node.cmd
-a--- 10/21/2014 11:29 PM 1819 setup_web.cmd
-a--- 2/5/2015 9:37 PM 272 www
www
#!/usr/bin/env node
var debug = require('debug')('ExpressApp3');
var app = require('../app');
app.set('port', process.env.PORT || 3000);
var server = app.listen(app.get('port'), function() {
debug('Express server listening on port ' + server.address().port);
});
app.js
//...
var handlebars = require('express-handlebars').create(config.handlebars);
app.set('views', path.join(__dirname, 'views'));
app.engine('.hbs', handlebars.engine);
app.set('view engine', '.hbs');
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(require('stylus').middleware(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'public')));
web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your Node.js application, please visit
http://go.microsoft.com/fwlink/?LinkId=290972
-->
<configuration>
<appSettings>
<!--
<add key="StorageAccountName" value="" />
<add key="StorageAccountKey" value="" />
<add key="ServiceBusNamespace" value="" />
<add key="ServiceBusIssuerName" value="" />
<add key="ServiceBusIssuerSecretKey" value="" />
-->
</appSettings>
<system.webServer>
<!-- mimeMap enables IIS to serve particular file types as specified by fileExtension. -->
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<modules runAllManagedModulesForAllRequests="false" />
<!-- Web.Debug.config adds attributes to this to enable remote debugging when publishing in Debug configuration. -->
<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.jade"/>
<!-- indicates that the server.js file is a Node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="/bin/www" verb="*" modules="iisnode" />
</handlers>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin" />
</hiddenSegments>
</requestFiltering>
</security>
<rewrite>
<rules>
<clear />
<rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="iisnode.+" negate="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="bin\www" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我就是这样解决的 我将项目中的www文件从/bin/www移动到根目录。 www
var app = require('../app');
到
var-app=require('./app')
然后将my web.config更改为:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your Node.js application, please visit
http://go.microsoft.com/fwlink/?LinkId=290972
-->
<configuration>
<appSettings>
<!--
<add key="StorageAccountName" value="" />
<add key="StorageAccountKey" value="" />
<add key="ServiceBusNamespace" value="" />
<add key="ServiceBusIssuerName" value="" />
<add key="ServiceBusIssuerSecretKey" value="" />
-->
</appSettings>
<system.webServer>
<!-- mimeMap enables IIS to serve particular file types as specified by fileExtension. -->
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<modules runAllManagedModulesForAllRequests="false" />
<!-- Web.Debug.config adds attributes to this to enable remote debugging when publishing in Debug configuration. -->
<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.hbs"/>
<!-- indicates that the server.js file is a Node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="www" verb="*" modules="iisnode" />
<!-- <add name="iisnode" path="bin/www" verb="*" modules="iisnode" />--!>
</handlers>
<security>
<requestFiltering>
<hiddenSegments>
<!--<remove segment="bin" />-->
</hiddenSegments>
</requestFiltering>
</security>
<rewrite>
<rules>
<clear />
<rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="iisnode.+" negate="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<!--<action type="Rewrite" url="bin\www" />-->
<action type="Rewrite" url="www" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我就是这样解决的 我将项目中的www文件从/bin/www移动到根目录。 www
var app = require('../app');
到
var-app=require('./app')
然后将my web.config更改为:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your Node.js application, please visit
http://go.microsoft.com/fwlink/?LinkId=290972
-->
<configuration>
<appSettings>
<!--
<add key="StorageAccountName" value="" />
<add key="StorageAccountKey" value="" />
<add key="ServiceBusNamespace" value="" />
<add key="ServiceBusIssuerName" value="" />
<add key="ServiceBusIssuerSecretKey" value="" />
-->
</appSettings>
<system.webServer>
<!-- mimeMap enables IIS to serve particular file types as specified by fileExtension. -->
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<modules runAllManagedModulesForAllRequests="false" />
<!-- Web.Debug.config adds attributes to this to enable remote debugging when publishing in Debug configuration. -->
<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.hbs"/>
<!-- indicates that the server.js file is a Node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="www" verb="*" modules="iisnode" />
<!-- <add name="iisnode" path="bin/www" verb="*" modules="iisnode" />--!>
</handlers>
<security>
<requestFiltering>
<hiddenSegments>
<!--<remove segment="bin" />-->
</hiddenSegments>
</requestFiltering>
</security>
<rewrite>
<rules>
<clear />
<rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="iisnode.+" negate="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<!--<action type="Rewrite" url="bin\www" />-->
<action type="Rewrite" url="www" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我今天也遇到了这个问题。我是node的新手,所以我不确定这是否是最好的方法,但这对我来说很有效 我在app.js的早期添加了这个
process.chdir(path.join(process.cwd(), '..'));
我今天也遇到了这个问题。我是node的新手,所以我不确定这是否是最好的方法,但这对我来说很有效 我在app.js的早期添加了这个
process.chdir(path.join(process.cwd(), '..'));
尝试将所有
path.join(\uu dirname,
替换为path.join(_dirname,“…”,
似乎走在了正确的道路上,它现在在D:\home\site中寻找,但是,这不是一个可持续的解决方案,因为本地机器上没有任何东西可以工作。目录结构是什么样子的?app.js和www在哪里?见上文。已经发布。我很接近了。你的建议是正确的。尝试替换所有path.join(_dirname,
带有path.join(uu dirname,“…”,
似乎走在了正确的道路上,它现在在D:\home\site中寻找,但这不是一个可持续的解决方案,因为本地机器上没有任何东西可以工作。目录结构是什么样子的?app.js和www在哪里?见上文。已经发布。我越来越接近了。你的建议是正确的。事实上,我找到了一个更好的way、 再次假设这样做是可以的。将process.chdir(_dirname);添加到app.jsactual process.chdir(_dirname);将允许应用程序在本地和Azure上运行。如果使用“join”方法,它在我的localI上不起作用实际上是一种更好的方式,再次假设这样做是可以的。将process.chdir(_u dirname);添加到app.jsactual process.chdir(_dirname);将允许应用程序在本地和Azure上运行。如果使用“加入”方法,则它在我的本地应用程序上不起作用