Google app engine (path file) - node.js

I am trying to get google app engine to work using node.js and puppeteer
It runs fine on local dev and node.path there is just dir / index.html and pupeteer can run it.
However when I deploy it as app engine flexible, it suddenly makes the path /app/index.html ans obviously puppeteer can't read it like it could in node.
Will update the question with code once I get home and not using phone.
Thanks!

It looks like you are running your application in Google App Engine with Flexible environment. What Flex does is to dockerize your application. At least for python the application is then placed in the /app directory, which is not unheard of for when executing python in Docker.
You can read more it in the official Google's GitHub repository for 'gcr.io/google_appengine/python' source for more details.
Note: you can debug the running Flex instance or even download the container built for your application.

Related

index.html not found while deploying MERN app to render.com

I was trying to deploy my MERN based E-commerce website on render.com, after the render terminal shows the build was successful the the webpage shows the error as,
{“message”:“ENOENT: no such file or directory, stat ‘/opt/render/project/src/frontend/build/index.html’”,“stack”:null}
I’m a complete beginner to render and MERN too,
I have no bulid folder in my local
then I tried to create another test app by npx create-react-app test to check if build folder is actually present in there or not, But it is not there, I’m totally in Confused now…
I’m Giving my repo here → stunning spark
I just want to have clear answers for my questions(Please!!!)
Things I want to change in my directory to deploy and host my app Successfully.
Things Need to be configured in the render’s settings
Thanks in Advance!!!
I just want to deploy and host my application on render.com
Just run npm run build into your frontend folder and do check you have removed the "build" keyword from the .gitignore file because it won't let you push the build folder to GitHub and you are good to go.

Creating Reactjs app production build without using node

We have just a single webpage with some links on clicking them it will redirect to different sources. As of now we are using "npm run build" to create the production package.
But because of the build files having dependencies with node, i cannot host it in a particular server.
Is there a way to create the Reactjs production build without using node ?
I suggest using Netlify to host your react app easily .
Below are some resources that can help you along the way.
https://www.netlify.com/with/react/
https://www.youtube.com/watch?v=sGBdp9r2GSg
You can have a build and upload it manually to your Netlify account,
You can use the CLI (netlify-cli) or you can your account to git .
Similar approach can be followed with git pages for example.
What packages do you have in your package.json file? Did you use a React project template that uses Node server-side features? It seems like you want to host your React project statically, not necessarily get rid of Node and npm.
For example, I've worked on lots of React projects using npm and create-react-app that we were able to host with a .NET backend and Microsoft IIS (instead of Node). The output is .html, .js, and other static files that you can host anywhere.
When you build a react app, the files at folder build contains everything it needs to run
If your hosting server hasn't integration with CI/CD, then you must deploy manually only the build folder, not the root folder (the folder that contains package.json).
I believe your issue is just a confusion/misunderstanding on how react works, how to deploy it, and how to run it.
React needs to be built on an environment where node, npm, and other tools are available. It can be on a build server or in your local machine.
After built, react app is just a folder with a bunch of html, css, js files which will run on the client browser, so, there's no dependency on NODE anymore.
These static files must be served with a simple static file server (apache, nginx, iis, etc),
I recommend you build the app locally on your machine and then deploy manually to your host through ftp, ssh or web interface.
If react is overkill to your needs, then don't use it.
The best approach is to host it in a cloud service that can do the full CI/CD integrated with git, all automated (Google GCP, AWS, Azure, Netlify, etc)

how to deploy a reacjs application in linux?

newbie in node and reactjs. I created a sample application with create-react-app. I ran npm run build to build the project and once successfully built saw following .
what does the static server mean here. I am planning to build a app, not just static web pages. will these steps to build and deploy work, if I copy the build folder to my development box and ran the following commands.
do i need to install any web server for it work in a linux dev box? how does the deployment work in nodejs/linux work, compared to like in microsoft box , you have to install IIS web server then deploy the website under it.
The build folder is ready to be deployed.
You may serve it with a static server:
npm install -g serve
serve -s build
In the developing phase you can use npm start to start a dev server that auto reloads on changes. (Pretty neat).
When you want to host your app you should use the npm run build command and deploy it as a static website. You can use a basic Apache Server for that. Your build folder should contain an index.html and various js files that will be loaded when a user requests your website.
Voilá you hosted your react app ;)

How to download Node.js project deployed on Google Cloud

I have deployed the Node.js code on Google Cloud using following command:-
gcloud app deploy
So, How to download Node.js project deployed on Google Cloud.
I'm not sure but if you need Tomcat server then set and deploy node.js application inside by creating a folder and add the dist folder files in it.
npm install --save #google-cloud/storage
At this point in time it is only possible to download your app's source code for Java, Python, PHP and Golang. The instructions are similar for Python, Golang and PHP:
appcfg.py -A [YOUR_PROJECT_ID] -V [YOUR_VERSION_ID] download_app [OUTPUT_DIR]
where:
[YOUR_PROJECT_ID] is your GCP project ID.
[YOUR_VERSION_ID] is the version ID of your application that you want to download.
[OUTPUT_DIR] is the full directory path to where you want your files downloaded.
In Java you use appcfg.sh:
appcfg.sh -A [YOUR_PROJECT_ID] -V [YOUR_VERSION_ID] download_app [OUTPUT_DIR]
See the link above and also the reference for Java and Python, PHP, Golang

deploy to google cloud platform flex env does not include directories?

AFAIK when using the google cloud sdk shell to deploy to the google cloud platform flex environment the deploy does not include the directories. For example, I'm following this nodejs express tutorial - https://cloud.google.com/nodejs/resources/frameworks/express. I can run the app locally. I deploy using gcloud app deploy running it in the same directory as app.yaml. However, after the deployment I get an application startup error:
node ./bin/www:
module.js:471`
throw err;
Error: Cannot find module '/app/bin/www'
I am able to deploy and run the hello world nodejs tutorial app, but that app has no sub-directories. However, if I modify that app to use EJS and put .ejs files in a 'views' folder and then deploy, the deploy works but the views folder is missing! I've verified that it is missing by using 'fs' in app.js to print out the files and directories of the current folder and guess what - NO directories except the node_modules folder which gets created during the deployment.
I've also tried deploying a python flask app that seems to have the same error (basically it cannot find a template because the templates folder does not exist...).
Has anyone else experienced this? Do I need to do something special in the deploy? I'm very surprised that not even Google's own sample tutorial app does not deploy.
Thanks!
I spent my whole day on the same issue. It looks like it was a problem with the new gcloud sdk shell. You can downgrade your version by 'gcloud components update --version=137.0.1'
It workes for me

Resources