React Boilerplate Build to External Hosting Server - node.js

Really have some difficulties building React Boilerplate (https://github.com/react-boilerplate/react-boilerplate) to copy built files to external hosting server.
After npm run build command I FTP all generated files into a separate folder at my remote host, say, http://example.com/test/react.
However, all paths inside the app are pointing to / path, so on deeper level (/test/react) the app would not load.
I have not found anything in documentation about this for React Boilerplate. Any help or suggestion?

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 setup production environment for Vue and deploy app into environment

I have developed a Vue app and trying to build a dev/QA/PROD environment for the same. I knew that when i use 'npm run build', it will create dist folder with set of files/folders under it. Here i just want to know following things
What would be the minimal Server/Environment to execute dist files.?Is node setup enough to execute and how?
How to deploy dist folder to specific environment?Will it be through Git?
Any web technology that can serve static files would do the trick.
The index.html file contained in the dist folder has links to all the javascript, css, images necessary for your app to function correctly.
So your web server has to serve index.html, and the other files have to be located in a folder accessible from any client online.
With node you can do as explained here:
https://expressjs.com/en/starter/static-files.html
You can also use your github account and github pages:
https://www.youtube.com/watch?v=2MsN8gpT6jY

How can I integrate two different servers like Angular and NodeJs?

I'm new in Angular and NodeJS. I finished all the basic documentation, and now I'm doing tutorials. My question is about the architecture.
Following the angular tutorial, you create a new server:
ng new new-project
That creates a whole server listening to port 4200, you learn and work with angular, learn about directives, etc.
Then you create a server with node, configure routes, etc.
But how these two servers live together?
What do you recommend me to join them?
This is a node server. The angular part are just two files
This is the server created with ng serve. The angular part is so much complicated
Angular project is not a server. Angular is framework to create front-end page/app. Angular-cli command ng serve is used to build application and start a web server on localhost.
When you build your page with angular use angular-cli command ng build --prod to build your page ( more info about ng build command). The build artifacts will be stored in the dist/ directory of your project.
If you want to host angular page with node - copy file from projektFolder/dist to catalog when node can have access to copy files. In node you can use express library to host static files:
app.use('/myangularproject', express.static('myangularproject')) //host static files`
More info about hosted static files in node and express
EDIT
You use Angular CLI to build an angular application. This is an additional tool for working with angular and you do not have to use it.
Angular cli is a command line interface to scaffold and build angular apps using nodejs style (commonJs) modules. Not only it provides you scalable project structure, instead it handles all common tedious tasks for you out of the box
ng serve
ng serve is a tool from angular cli. When you call this command your project is build in memory and serve it via webpack-dev-server. It is used for quick preview and development of the project. If this command is confusing for you then you can use the npm script npm start.
The CLI supports running a live browser reload experience to users by running ng serve. This will compile the application upon file saves and reload the browser with the newly compiled application. This is done by hosting the application in memory and serving it via webpack-dev-server. doc
ng build
ng build compiles the application into an output directory.
Compiles an Angular app into an output directory named dist/ at the given output path. Must be executed from within a workspace directory.
When you use command ng new Angular CLI add all necessary files to develop your application. Some of them are used to configure the project e.g tslint.json, tsconfig.json, angular.json ... Do not host these files only result files from the use of the ng build command (/dist directory).
Angular CLI compiles your project into several files (try ng build and look how many files do you have in /dist. You must host all of them. These are static files. You do not need a special server like php files. You can host them using a regular file server. I don't know what you concern use in the node to host static files. If they use express you can use express.static(). More info at the top.

Configuring a server to serve a vue app [duplicate]

This question already has answers here:
Which command do I use to generate the build of a Vue app?
(19 answers)
Closed 4 years ago.
I think I have a bit of a mess here. I have my vue app running in my localhost environment. I want to deploy to a server I have hired. Which are the steps to accomplish this?
I have installed nodejs and npm on the server. At a first glance I tried to go the way I always did when using php, running nodejs app through apache server but it seems it is not the best option from what I read. In my local machine I run:
npm run serve
to start a server to run my vue app locally. Should I do same thing on my remote server? Are there better options?
Should I do same thing on my remote server?
Definitely no.
Notice in your package.json file you should have a script called "build", i.e. you can execute it with the command:
$ npm run build
Once executed, it should compile your Vue project and place the resulting files in a dist folder at the root of your project.
Notice that these files are plain HTML, JS (for browser, since Vue is only for front end) and CSS (plus any of your project assets if applicable).
Since you are familiar with PHP, you should know what to do with those files. Should your project be "simple" and not require backend services (like AJAX, REST, etc.), you can actually serve them on a simple server (no need for PHP, Node, etc.).
Otherwise, you should have plenty tutorials and resources online explaining how to publish those files on a simple server.

Resources