【问题标题】:Error When Publishing .NetCore Angular 6 to Azure将 .NetCore Angular 6 发布到 Azure 时出错
【发布时间】:2018-10-11 10:37:17
【问题描述】:

我有一个应用程序在本地运行良好,但在 Azure AppService 中运行时出错:

InvalidOperationException:NPM 脚本“开始”退出,但未指示 Angular CLI 正在侦听请求。错误输出是:npm ERR!错误:ENOENT,打开 'D:\home\site\wwwroot\ClientApp\node_modules\start\package.json'

如果有人认为他们可以提供帮助,我可以提供更多信息。

【问题讨论】:

  • 您正在尝试在 Azure 上以开发模式启动 Angular 应用程序?
  • 是这个问题,我应该进入发布模式吗?
  • 运行ng build --prod会在dist目录下生成编译好的静态文件,然后你就可以像其他静态文件一样暴露静态文件了。

标签: angular azure angular6 asp.net-core-2.0


【解决方案1】:

该错误与角度路线有关,服务无法识别它们。

您是否创建了 webconfig 文件?

我有同样的错误,并且能够像修复它一样

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Angular Routes" stopProcessing="true">
                    <match url=".*NEWPDS.*" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                     <action type="Rewrite" url="./index.html" />
                </rule>

            </rules>
            <outboundRules>

            </outboundRules>
        </rewrite>
    </system.webServer>

</configuration>

使用 IIS 时。

【讨论】:

  • 我尝试在 my.csProj 的根目录中添加一个。恐怕同样的错误
  • 你必须声明你正在使用一个 web 配置文件来 angular cli 像 ;"apps": [ { "root": "src", "outDir": "dist", "assets" :[“图像”,“favicon.ico”,“web.config”],“索引”:“index.html”,“main”:“main.ts”,“polyfills”:“polyfills.ts”,“测试": "test.ts",
  • 我找到了一个教程,并认为我需要按照它来完成,因为我拥有的 angular.json 文件看起来与你的完全不同。
  • 感谢 Kutlu,您的建议很好。我又开始了,这有效:)
猜你喜欢
  • 1970-01-01
  • 2019-01-18
  • 2019-08-18
  • 1970-01-01
  • 1970-01-01
  • 2012-02-29
  • 1970-01-01
  • 1970-01-01
  • 2018-03-02
相关资源
最近更新 更多