简体   繁体   English

无法在 GAE 上部署 node.js 应用程序

[英]Cannot deploy node.js app on GAE

I'm having trouble deploying my node.js app to GAE.我在将 node.js 应用程序部署到 GAE 时遇到问题。

It's a simple app that connects to my Firebase and updates a value.这是一个连接到我的 Firebase 并更新值的简单应用程序。 Just to get started.只是为了开始。

Whenever I try to deploy the app it fails.每当我尝试部署应用程序时,它都会失败。 Runs fine locally.在本地运行良好。

I deleted my project and started a fresh one, and deployed the default 'hello-world' app after downloading the zip and it worked fine.我删除了我的项目并开始了一个新项目,并在下载 zip 后部署了默认的“hello-world”应用程序,它运行良好。

I installed firebase on the project via the cloud shell.我通过云外壳在项目上安装了 firebase。

Added添加

var Firebase = require("firebase"); 

to the app.js file and it no longer deploys.到 app.js 文件,它不再部署。

I am new to GAE and cannot understand why it won't deploy.我是 GAE 的新手,无法理解为什么它不会部署。 I feel like if i'm having trouble just including firebase in an app, I'm in for a tough time.我觉得如果我在应用程序中包含 firebase 时遇到问题,我会遇到困难。

This is the error I get.这是我得到的错误。 The only think I have added to the original hello-world app is the firebase dependency.我添加到原始 hello-world 应用程序的唯一想法是 firebase 依赖项。 I remove that and it deploys fine again.我删除了它,它再次部署得很好。

Updating service [default]...failed.更新服务 [默认]...失败。 ERROR: (gcloud.preview.app.deploy) Error Response: [13] Timed out when starting VMs.错误:(gcloud.preview.app.deploy) 错误响应:[13] 启动虚拟机时超时。 It's possible that the application code is unhealthy.应用程序代码可能不健康。 (0/2 ready, 2 still deploying). (0/2 准备就绪,2 个仍在部署)。

Any help would be greatly appreciated.任何帮助将不胜感激。

I fixed the issue by installing the firebase npm on my local machine again.我通过在本地机器上再次安装 firebase npm 解决了这个问题。 I noticed when I was installing it on the server (even with --save) it wasn't updating the package.json file for some reason and it hadn't updated it locally either.我注意到当我在服务器上安装它时(即使使用--save)它由于某种原因没有更新 package.json 文件,也没有在本地更新它。 But it still ran on my local machine without the package mentioning a firebase dependency.但它仍然在我的本地机器上运行,而没有提到 firebase 依赖的包。 Not sure why that would be the case.不知道为什么会这样。

It seems to be working now.它现在似乎正在工作。

Before you can require the "firebase" package you need to install it.在您需要“firebase”包之前,您需要安装它。

To install the latest version of the package using the command line:要使用命令行安装最新版本的软件包:

  1. Navigate to the project root directory导航到项目根目录
  2. Run npm install --save firebase运行npm install --save firebase

You will now have Firebase, and all the packages that it depends on, installed in your app.您现在将在您的应用中安装 Firebase 及其依赖的所有软件包。

The --save argument makes the command save the package installation configuration to the package.json file, so that the package is installed when you run the npm install command to set up the project on another computer, or when your app is deployed to Google App Engine. --save参数使该命令将包安装配置保存到package.json文件中,以便在您运行npm install命令在另一台计算机上设置项目时,或在您的应用程序部署到 Google 时安装该包应用引擎。

You can check the logs for error.您可以检查日志是否有错误。 To check it goto your project at google console (console.cloud.google.com) and then Menu-> Logs.要检查它,请在 google 控制台 (console.cloud.google.com) 上转到您的项目,然后转到菜单-> 日志。

Usually this error comes when app couldn't start while deploying.通常当应用程序在部署时无法启动时会出现此错误。 1st check if the app local environment. 1st 检查应用程序本地环境。 If it is working fine then check if any environment variable is required to set and not set properly on cloud.如果它工作正常,则检查是否需要在云上设置任何环境变量并且未正确设置。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM