我想在Azure Web中运行角色4 univeral。我部署了代码,但是我在web.config中遇到了一些麻烦(我认为是这样)。位于带角度通用的web.config
的server.js在蒸馏水文件夹,所以我设置在web.config中 “DIST/server.js” 路径,但server.js运行时,它提供了一个错误:
ENOENT:没有这样的文件或目录中,打开'D:\ home \ site \ wwwroot \ dist \ dist \ browser \ index.html'
如果我从路径中删除“dist”,它将会是404.如果我从中删除“dist”
const DIST_FOLDER = join(process.cwd(), 'dist'); in server.js
它会给我一个错误:
ENOENT:没有这样的文件或目录,打开 'd:\家\网站\ wwwroot的\浏览器\ index.html在'
或者双DIST,或根本没有DIST可言。
的web.config文件看起来是这样的:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<webSocket enabled="false" />
<handlers>
<add name="iisnode" path="dist/server.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^dist/server.js\/debug[\/]?" />
</rule>
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="dist/server.js"/>
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
</hiddenSegments>
</requestFiltering>
</security>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
</configuration>
的server.js代码:
const PORT = process.env.PORT || 8080;
const DIST_FOLDER = join(process.cwd(), 'dist');
const app = express();
const template = readFileSync(join(DIST_FOLDER, 'browser', 'index.html')).toString();
const { AppServerModuleNgFactory } = require('main.server');
app.engine('html', (_, options, callback) => {
const opts = { document: template, url: options.req.url };
renderModuleFactory(AppServerModuleNgFactory, opts)
.then(html => callback(null, html));
});
app.set('view engine', 'html');
app.set('views', 'src');
app.get('*.*', express.static(join(DIST_FOLDER, 'browser')));
app.get('*', (req, res) => {
res.render('index', { req });
});
app.listen(PORT,() => {
console.log(`listening on http://localhost:${PORT}!`);
});
问题是它使得错误“ENOENT:没有这样的文件或目录,打开D:\ home \ site \ wwwroot \ browser \ index.html”,根本没有dist文件夹。 – RaShe