这个问题最近才出现,我们已经使用这种方法在Azure上托管的Web应用程序上部署了数百次,但由于某种原因,它在部署的安装阶段经常失败,声明它找不到package.json文件,我已经检查了代码十几次,现在试图找出什么变化,但我没有注意到任何东西。所以我希望有人注意到一些我没有与工作流文件。我在这里引用了这篇文章:然而,它并没有完全修复我的流。
下面是yml
文件:
on:
push:
branches:
- development
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js version
uses: actions/setup-node@v1
with:
node-version: '18.x'
#zips the repo, helps with transferring a large amount of files
- name: Zip artifact for deployment
run: zip release.zip ./* -r
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: node-app
path: release.zip
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'development'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: node-app
- name: unzip artifact for deployment
run: unzip release.zip
# removes the release.zip from being pushed to the final deployment
- name: Remove File
# You may pin to the exact commit or the version.
# uses: JesseTG/rm@94440f309afcc4c37e6bf63eb0feca9e94dee5a3
uses: JesseTG/rm@v1.0.0
with:
# The file path to remove
path: release.zip
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'redacted'
slot-name: 'redacted'
publish-profile: ${{ redacted }}
package: .
在每次push时,我都会得到相同的错误,即无法找到项目的package.json,即使项目结构自上次成功push后没有更改。结构:
--project:
---github/workflows
---public
---src
--.gitignore
--.prettierrc.cjs
--package-lock.json
--package.json
## this is file is just for azure, it essentially sets up a small node server, that serves up the build folders index.js
--server.js
1条答案
按热度按时间3bygqnnd1#
检查github ticket # 47中提供的解决方案是否可以帮助您解决此问题。
我也尝试过通过NodeJS Web应用程序从我的终端复制,并且能够成功地构建和部署。
项目结构:
yml文件:
我可以成功构建和部署Web应用程序,如下所示: