简体   繁体   English

Azure 应用服务在部署 REACT JS 应用程序时出错

[英]Azure App Service Getting error while deploying REACT JS application

Getting error while deploying to azure app services from the editor.从编辑器部署到 azure 应用服务时出错。

4:48:55 pm ppdedsrftwu2-appservice1: Starting deployment...
4:48:56 pm ppdedsrftwu2-appservice1: Creating zip package...
4:49:00 pm ppdedsrftwu2-appservice1: Zip package size: 1.09 MB
4:49:04 pm ppdedsrftwu2-appservice1: Fetching changes.
4:49:06 pm ppdedsrftwu2-appservice1: Updating submodules.
4:49:06 pm ppdedsrftwu2-appservice1: Preparing deployment for commit id '2a73dbd291'.
4:49:06 pm ppdedsrftwu2-appservice1: Repository path is /tmp/zipdeploy/extracted
4:49:06 pm ppdedsrftwu2-appservice1: Running oryx build...
4:49:06 pm ppdedsrftwu2-appservice1: Command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform nodejs --platform-version 10 -i /tmp/8d856447f426192 -p compress_node_modules=tar-gz --log-file /tmp/build-debug.log 
4:49:07 pm ppdedsrftwu2-appservice1: Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
4:49:07 pm ppdedsrftwu2-appservice1: You can report issues at https://github.com/Microsoft/Oryx/issues
4:49:07 pm ppdedsrftwu2-appservice1: Oryx Version: 0.2.20200805.1, Commit: e7c39ede513143e9d80fd553f106f04268d770d4, ReleaseTagName: 20200805.1
4:49:07 pm ppdedsrftwu2-appservice1: Build Operation ID: |lvjLop9mFGA=.426fac1c_
4:49:07 pm ppdedsrftwu2-appservice1: Repository Commit : 2a73dbd2834715ba1fee5082d13b60
4:49:07 pm ppdedsrftwu2-appservice1: Detecting platforms...
4:49:07 pm ppdedsrftwu2-appservice1: Could not detect any platform in the source directory.
4:49:07 pm ppdedsrftwu2-appservice1: Error: Couldn't detect a version for the platform 'nodejs' in the repo.
4:49:09 pm ppdedsrftwu2-appservice1: Error: Couldn't detect a version for the platform 'nodejs' in the repo.\n/opt/Kudu/Scripts/starter.sh oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform nodejs --platform-version 10 -i /tmp/8d856447f4292 -p compress_node_modules=tar-gz --log-file /tmp/build-debug.log 
4:49:20 pm ppdedsrftwu2-appservice1: Deployment failed.

Have defined all the necessary settings in the portal.已在门户中定义所有必要的设置。

SCM_DO_BUILD_DURING_DEPLOYMENT=true
WEBSITE_NODE_DEFAULT_VERSION=12
WEBSITES_PORT=3000
WEBSITE_HTTPLOGGING_RETENTION_DAYS=7

Tried with node version 10 also but still the same error.也尝试使用node版本10 ,但仍然出现相同的错误。

Connected with MS Support team they suggested to make the SCM_DO_BUILD_DURING_DEPLOYMENT= FALSE .与 MS 支持团队联系,他们建议使SCM_DO_BUILD_DURING_DEPLOYMENT= FALSE After making this as false i am able to deploy the app.将此设置为 false 后,我可以部署该应用程序。 But the strange thing is with this option enabled i was doing earlier deployments and it was working.但奇怪的是,启用此选项后,我正在进行早期部署并且它正在工作。

In my case, I had the node app in a subdirectory, and this was causing this error in GitHub Actions job.就我而言,我在子目录中有节点应用程序,这导致 GitHub 操作作业中出现此错误。 Explicitly setting the working directory in the yml file fixed this.在 yml 文件中显式设置工作目录修复了这个问题。 ie IE

- name: npm install, build, and test
    working-directory: ./subdirectory
    run: |
      npm install
      npm run build --if-present
      npm run test --if-present

If you're doing a deployment from ie, Visual Studio Code and deploying the dist/... folder then you wouldn't want to try and actually do a build hence setting SCM_DO_BUILD_DURING_DEPLOYMENT=false .如果您正在从即 Visual Studio Code 进行部署并部署 dist/... 文件夹,那么您不想尝试实际进行构建,因此设置SCM_DO_BUILD_DURING_DEPLOYMENT=false

There is not a running node.js server to actually do a build on the agent pool deployment pipeline.没有正在运行的 node.js 服务器实际在代理池部署管道上进行构建。 Azure devops or Jenkins per se would actually have an agent pool to do a "proper (air quotes)" build. Azure devops 或 Jenkins 本身实际上会有一个代理池来执行“适当的(空引号)”构建。 Yes, you're code is running on node hence the setting you choose when setting up the web app .是的,您的代码在节点上运行,因此您在设置web app时选择的设置。 So those 2 things are not the same.所以这两件事是不一样的。 Rather, DevOps.相反,DevOps。

I didn't find it in the documentation so appreciate the answer and responses here;我没有在文档中找到它,所以感谢这里的答案和回复; but, I just wanted to give more context to the answer.但是,我只是想为答案提供更多背景信息。

It's an upgrade to visual studio web apps deployment to potentially utilize other build methods like described in an answer here about github actions.这是对 visual studio web 应用程序部署的升级,可能会利用其他构建方法,如此处关于 github 操作的答案中所述。

I also struggled with this issue.我也为这个问题而苦苦挣扎。

Two things helped me:有两件事帮助了我:

When deploying from the Azure App service extension:从 Azure 应用服务扩展部署时:

  1. Understanding that your root NodeJS application folder must be the root folder that is open in your explorer in vscode.了解您的根 NodeJS 应用程序文件夹必须是在 vscode 的资源管理器中打开的根文件夹。

If your NodeJS application is in a subfolder, azure wont be able to build ( or identify your node platform: hence the error message that you are seeing ) the scripts in your root folder.如果您的 NodeJS 应用程序位于子文件夹中,azure 将无法构建(或识别您的节点平台:因此您看到的错误消息)根文件夹中的脚本。

By far the easiest way to resolve this is to open vscode in the root folder ( the folder where your package.json file is located.到目前为止,解决此问题的最简单方法是在根文件夹(package.json 文件所在的文件夹)中打开 vscode。

  • Also: When you click the deploy button on your vscode Azure App service extension: it might allow you to specify the folder to be deployed.另外:当您单击 vscode Azure 应用程序服务扩展上的部署按钮时:它可能允许您指定要部署的文件夹。

部署按钮位置

  1. You can try to add the Application setting: SCM_DO_BUILD_DURING_DEPLOYMENT with the value of FALSE and Deployment slot setting of unchecked.您可以尝试添加应用程序设置:SCM_DO_BUILD_DURING_DEPLOYMENT,其值为 FALSE 且 Deployment slot 设置为未选中。

This is on the azure portal under configuration - application settings - add +这个在azure传送门下配置-应用设置-添加+

Remember to click that save button after adding new application settings..... because azure... lol.请记住在添加新的应用程序设置后单击该保存按钮..... 因为 azure... 大声笑。

But i think this is mostly way to delay your app building until the files are copied.但我认为这主要是在复制文件之前延迟应用程序构建的方法。

Last thing: If you are deploying from Github: Make sure that your nodeJS app is also in the root folder of the Github repo.最后一件事:如果您从 Github 进行部署:请确保您的 nodeJS 应用程序也在 Github 存储库的根文件夹中。 If it is not you will need to update the workflow file to change the folder to the subfolder.如果不是,您将需要更新工作流文件以将文件夹更改为子文件夹。

You just need to add cd yourfoldername above the line where it says npm install and commit the workflow change to the repo.您只需要在显示 npm 安装的行上方添加 cd yourfoldername 并将工作流更改提交到 repo。

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 azure 上部署反应应用程序后出现错误 - After deploying the react application on azure getting error 尝试将 React 应用程序部署到 Azure 应用程序服务时出错 - getting error while trying to deploy a React app to Azure App Service 在 heroku 上部署 react.js 项目时出现应用程序错误 - Application error while deploying react.js project over heroku 部署到 heroku 的节点反应应用程序时出现以下错误 - Getting following error while deploying to node react app to heroku 将React js和Node App部署到AWS时出错 - Error while deploying react js and node app to aws 在 github 页面上部署反应应用程序时出现错误:“react-dom.production.min.js:216 TypeError: Object(...) is not a function” - Getting error : "react-dom.production.min.js:216 TypeError: Object(...) is not a function" while deploying react app on github pages 用于将 react.js 代码部署到节点 Azure 应用服务的 Azure cli 命令 - Azure cli command for deploying react.js code to node Azure App Service 在Azure上部署时无法将Node.js应用连接到React.js应用 - Unable to connect Node.js app to React.js app while deploying on Azure 无法在 Azure App 服务上部署 React JS 应用程序 - Unable to deploy React JS application on Azure App service 在azure上部署React应用程序 - Deploying React application on azure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM