问题
This error appears when the code is built and deployed to Azure. When the code is run locally using VSCode this doesn't appear in the console. Any help regarding this matter is appreciated.
Manifest file code :
{
"name": "",
"icons": [
{
"src": "assets/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
The file is referenced in the index.html as follows
<link rel="manifest" href="assets/manifest.json">
回答1:
Fixed it by using crossorigin="use-credentials" in the tag.
<link rel="manifest" crossorigin="use-credentials" href="./assets/manifest.json">
回答2:
Try to add a name in the name property Remember It should not be empty, contain spaces not it should contain uppercase letters.
回答3:
I had the same error today with my Angular 6 project hosted on Azure.
Here's my fix:
in my "web.config" file:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
Add these lines:
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
Result:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
<rewrite>
<rules>
<rule name="Angular" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
That worked for me, hope it works for you too! :)
Related thread: How to allow download of .json file with ASP.NET
来源:https://stackoverflow.com/questions/54127634/angular-6-application-manifest-line-1-column-1-unexpected-token