我尝试通过 github 操作将 shell Next.js 应用程序上传到 Azure Web 服务,但出现错误。
“错误:在‘./.next’目录中找不到生产版本。在启动生产服务器之前尝试使用‘next build’构建您的应用程序。”
我的神器的文件夹结构是
应用程序
节点模块
包装
服务器.js
我的启动命令是node server.js
这是我的 yml 文件:
name: Build and deploy Node.js app to Azure Web App
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js version
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: npm install, build, and test
run: |
npm install
npm run build
- name: Copy static files
run: |
cp -R ./.next/static ./.next/standalone/.next/static
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: app
path: .next/standalone
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: Production
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: app
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'frontend'
slot-name: 'Production'
package: .
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE }}
我已关注:
https://inmeta.medium.com/deploy-next-js-to-azure-3- effective-strategies-for-modern-developers-86a41c0f9d92和https://www.youtube.com/watch? v=H4amPlNBTf0 如何配置的示例,但仍然遇到问题。
有谁知道为什么会这样吗?