Cannot deploy node.js app on GAE - node.js

I'm having trouble deploying my node.js app to GAE.
It's a simple app that connects to my Firebase and updates a value. 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.
I installed firebase on the project via the cloud shell.
Added
var Firebase = require("firebase");
to the app.js file and it no longer deploys.
I am new to GAE and cannot understand why it won't deploy. I feel like if i'm having trouble just including firebase in an app, I'm in for a tough time.
This is the error I get. The only think I have added to the original hello-world app is the firebase dependency. 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. It's possible that the application code is unhealthy. (0/2 ready, 2 still deploying).
Any help would be greatly appreciated.

I fixed the issue by installing the firebase npm on my local machine again. 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. But it still ran on my local machine without the package mentioning a firebase dependency. 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.
To install the latest version of the package using the command line:
Navigate to the project root directory
Run npm install --save firebase
You will now have Firebase, and all the packages that it depends on, installed in your app.
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.

You can check the logs for error. To check it goto your project at google console (console.cloud.google.com) and then Menu-> Logs.
Usually this error comes when app couldn't start while deploying. 1st check if the app local environment. If it is working fine then check if any environment variable is required to set and not set properly on cloud.

Related

Deployment error. Build failed: Build error details not available. Firebase Cloud Functions

I reinstalled multiple times NPM and Node on my pc.
(npm version 7.4.3)
(node version v15.7.0)
I followed the procedure for configuring the Firebase CLI with:
npm install -g firebase-tools
and firebase init and firebase deploy and the configuration seems to work fine.
The problem I'm facing happens when I open the index.js file and I uncomment the stock helloWorld function which looks like this:
exports.helloWorld = functions.https.onRequest((request, response) => {
functions.logger.info("Hello logs!", {structuredData: true});
response.send("Hello from Firebase!");
});
I run firebase deploy and I receive this error
functions[helloWorld(us-central1)]: Deployment error.
Build failed: Build error details not available. Please check the logs at https://console. {urlStuff}
Functions deploy had errors with the following functions:
helloWorld
To try redeploying those functions, run:
firebase deploy --only "functions:helloWorld"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
I honestly don't know what to do now.
I tried multiple times to re install node and npm and re doing the Firebase CLI procedure but nothing seems to solve this problem, I still receive this Error when deploying.
The log error I receive is this :
textPayload: "ERROR: error fetching storage source: generic::unknown: retry budget exhausted (3 attempts): fetching gcs source: unpacking source from gcs: source fetch container exited with non-zero status: 1"
As suggested by this link provided by #Muthu Thavamani :
GCP Cloud Function - ERROR fetching storage source during build/deploy
Firebase CLI uses NodeJS version 12 while on my device I had version 15 installed.
Just use this guide to downgrade your version of NodeJS and everything works fine.
For me, it was because I was using an older version of Firebase CLI.
So I ran the upgrade command as suggested, and it worked.
sudo npm i -g firebase-tools
(My Node version is v15.6.0)
I had a similar problem and wasn't solved by changing node version. What I had to do is actually enter Container Repos and delete both worker & cache images. Then I got it running (using node v12.22.1 and npm v6.14.12).
It's much easier to find and fix issue by examining the actual logs by using this command to open the log
firebase functions:log
The specific issue will be visible there. I sometimes had error as simple as a missing packages in package.json
I wish they could show better info on the errors directly. but at least we can find them here.

Installed JsZip but its not working by grunt

I used https://stuk.github.io/jszip/ on my local machine and update all dependency by npm and used command grunt connect but this only showing web server started but on this url its not working.
$ grunt connect
Running "connect:server" (connect) task
Started connect web server on http://localhost:9999
Done, without errors.
even i have tested the app there is no error,
can anyone let me know how to get such type of projects from git-hub and run locally by npm or composer/bower.
I have used simple javascript instead of going with NodeJs and here my code is :
Here is Gist Code you can run.

Express app with Node-sass on Azure App Service

I have a basic node web application using express that has a dependency on the node-sass library.
This is being built on a Win64 server, so during the npm install part of the build it is downloading the x64 version of the binding binary due to the current environment.
When its deployed to Azure App Service it throws a runtime error due to incompatability with the node-sass binding binary, as node runs 32bit in Azure App Service...
Error: Missing binding
D:\home\site\wwwroot\node_modules\node-sass\vendor\win32-ia32-48\binding.node
Node Sass could not find a binding for your current environment:
Windows 32-bit with Node.js 6.x
Found bindings for the following environments:
- Windows 64-bit with Node.js 6.x
When i explicitly check in the 32bit binding and re-deploy i sometimes get a 502 gateway error...
502 - Web server received an invalid response while acting as a
gateway or proxy server. There is a problem with the page you are
looking for, and it cannot be displayed. When the Web server (while
acting as a gateway or proxy) contacted the upstream content server,
it received an invalid response from the content server.
and other times i simply get a 500, but it no longer writes the error to the log.
The app depends on node-sass-middleware package version 0.11 explicitly, which depends on node-sass 4.3.0.
Without any error logs i am at a dead end. Have you come across this issue before, and if so, how did you resolve it?
I leveraged Node-Sass Example App to have quick test, used local git to deploy it sample project to Azure Web Apps, which reproduced your issue.
Via the deployment log:
remote: Selected node.js version 7.4.0. Use package.json file to choose a different version.
remote: Selected npm version 4.0.5
And according the similar error message:
Found bindings for the following environments: - Windows 64-bit with Node.js 6.x
I specified the node.js version in package.json to:
"engines": {
"node": "= 6.9.1",
"npm": "> 3"
}
Then redeploy it to Azure via local git, and the sample works fine.
For your further 500 error, you can try to leverage App Service Editor to check the output of your website.
Enter the App Service Editor from Azure portal, switch to output section by clicking the show output button, then click run to start the application.
We eventually resolved this by swapping out node-sass-middleware for gulp-sass, and also adding an npm rebuild step for node-sass. The key difference here is that the css is now rendered during the build process via gulp. Running npm rebuild node-sass first would invoke the binding download to the build server (if necessary), and then a separate task would invoke a gulp task to render the css.
The remainder of our problem was due to the fact that the web.config specified app.js as the entry point, but express4 uses the bin/www file, and simply references app.js. The problem with bin/www being the entry point is that iisnode now uses bin as the working directory, which caused issues with root relative references.
Rather than waste any more time trying to figure out if we could configure a different working directory, we simply moved bin/www to ./server.js and changed the web.config to point to server.js
The express app now runs as expected on azure websites.

Meteor Buildpack for Cloud Foundry

I'm trying to get the meteor buildpack for cloud foundry running and its almost there except right at the end I get a node command not found error. I've confirmed that during the build I can run node and npm version commands. I get no errors until the instance fails to start.
Node gets installed into a folder called .vendor. I'm new to linux but is it possible that this folder isn't accessible at some point for some reason because of the dot? Meteor gets installed into a folder called vendor so I will try installing node there too. Can anyone think of something else to try?? I also tried changing the node folder to 777 in case it was a permissions thing. Far as I can tell the PATH variable is setup correctly.
I got the app deployed by converting to a node app and using the node buildpack but i'd prefer to use the meteor buildpack.

How to start an appfog locomotive.js app?

I'm using the node framework locomotive.js on an appfog instance. Installing this caused a slew of errors and I couldn't get the app to start. Reviewing the help materials and working with appfog support we were able to resolve that the issue had to do with the package.json file and specifically the invocation of lcm server.
What is correct package.json property?
You might check out https://github.com/hakaider/locomotive-appfog-sample
I just cloned it into my directory, ran npm install, then af update [my app name here] and it just worked.

Resources