gpt4 book ai didi

node.js - Nuxt 3 应用程序 GitHub Actions Build 中的 NewtonSoft.Json 异常

转载 作者:行者123 更新时间:2023-12-02 07:16:26 25 4
gpt4 key购买 nike

我们目前在新的 Nuxt3 静态 Web 应用程序的 GitHub Actions 中遇到 NewtonSoft.Json 构建问题。应用程序在本地完美构建和运行(npm run dev),但在尝试通过 GitHub 操作部署到 Azure 时,构建/部署过程失败。构建期间抛出的异常和 GitHub actions 工作流程 yaml 文件如下所示:

`**`Build Operation ID: 75d5ecf1017c042b
OS Type : bullseye
Image Type : jamstack

Detecting platforms...
Error: Oops... An unexpected error has occurred.
Error: Newtonsoft.Json.JsonReaderException: Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path '', line 1, position 1.
at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
at Newtonsoft.Json.Linq.JObject.Parse(String json)
at Microsoft.Oryx.Detector.ParserHelper.ParseJsonFile(ISourceRepo sourceRepo, String filePath) in /usr/oryx/src/Detector/ParserHelper.cs:line 86
at Microsoft.Oryx.Detector.Hugo.HugoDetector.IsHugoJsonFile(ISourceRepo sourceRepo, String\[\] subPaths) in /usr/oryx/src/Detector/Hugo/HugoDetector.cs:line 218
at Microsoft.Oryx.Detector.Hugo.HugoDetector.IsHugoApp(ISourceRepo sourceRepo, String& appDirectory) in /usr/oryx/src/Detector/Hugo/HugoDetector.cs:line 145
at Microsoft.Oryx.Detector.Hugo.HugoDetector.Detect(DetectorContext context) in /usr/oryx/src/Detector/Hugo/HugoDetector.cs:line 49
at Microsoft.Oryx.BuildScriptGenerator.Hugo.HugoPlatform.Detect(RepositoryContext context) in /usr/oryx/src/BuildScriptGenerator/Hugo/HugoPlatform.cs:line 61
at Microsoft.Oryx.BuildScriptGenerator.DefaultPlatformsInformationProvider.GetPlatformsInfo(RepositoryContext context) in /usr/oryx/src/BuildScriptGenerator/DefaultPlatformsInformationProvider.cs:line 53
at Microsoft.Oryx.BuildScriptGenerator.DefaultBuildScriptGenerator.GenerateBashScript(BuildScriptGeneratorContext context, String& script, List\`1 checkerMessageSink) in /usr/oryx/src/BuildScriptGenerator/DefaultBuildScriptGenerator.cs:line 75
at Microsoft.Oryx.BuildScriptGeneratorCli.BuildScriptGenerator.TryGenerateScript(String& generatedScript, Exception& exception) in /usr/oryx/src/BuildScriptGeneratorCli/BuildScriptGenerator.cs:line 63
at Microsoft.Oryx.BuildScriptGeneratorCli.BuildCommand.Execute(IServiceProvider serviceProvider, IConsole console) in /usr/oryx/src/BuildScriptGeneratorCli/Commands/BuildCommand.cs:line 278
at Microsoft.Oryx.BuildScriptGeneratorCli.CommandBase.OnExecute(IConsole console) in /usr/oryx/src/BuildScriptGeneratorCli/Commands/CommandBase.cs:line 87`**`
name: Azure Static Web Apps CI/CD

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main

jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ASHY_MUSHROOM_036506E0F }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: ".output/server" # Api source code path - optional
output_location: ".output/public" # Built app content directory - optional
###### End of Repository/Build Configurations ######

close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ASHY_MUSHROOM_036506E0F }}
action: "close"

作为故障排除的一部分,我还使用 nuxi 搭建了一个准系统 Nuxt3 静态 Web 应用程序,并配置了一个新的 Azure 静态 Web 应用程序,并且部署的应用程序没有出现问题。然而,一旦我集成了有问题的应用程序中的代码,我再次开始收到上述异常。有问题的应用程序也按原样部署到 Vercel,没有出现任何问题,因此这似乎是 Azure 特定的部署问题。归根结底,我不太确定为什么我们会在 Nuxt3/node 应用程序上遇到 Newtonsoft.Json.JsonReaderException,因为这是我希望在运行时在 .net 应用程序上看到的情况。

最佳答案

我尝试部署示例 Nuxt app 通过 github actions 部署成功,引用如下:-

Nuxt 应用程序在本地成功运行,如下所示:-

enter image description here

创建一个静态 Web 应用程序并从 github 存储库部署 Nuxt 应用程序,如下所示:-

enter image description here

enter image description here

enter image description here

Nuxt 应用程序已成功部署在 Azure 静态 Web 应用程序中,如下所示:-

enter image description here

我的 github 工作流程脚本:-

name: Azure Static Web Apps CI/CD

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main

jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_THANKFUL_GROUND_085802C10 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: ".output/server" # Api source code path - optional
output_location: ".output/public" # Built app content directory - optional
###### End of Repository/Build Configurations ######

close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_THANKFUL_GROUND_085802C10 }}
action: "close"

我的 github 存储库:-

enter image description here

enter image description here

我的package.json:-

{
"name": "nuxt-3-starter",
"version": "1.0.0",
"description": "My Nuxt 3 Test",
"author": "Nuzhat Minhaz",
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview"
},
"devDependencies": {
"nuxt": "3.0.0-rc.6"
}
}

您似乎在 Azure 平台级别遇到问题,请单击“诊断并解决问题”,然后单击“内容部署”以深入了解静态 Web 应用程序部署:-

enter image description here

您还可以启用 Application Insights 并检查 Application Insights 中的日志,如下所示以分析您的错误:-

enter image description here

关于node.js - Nuxt 3 应用程序 GitHub Actions Build 中的 NewtonSoft.Json 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76640058/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com