Install React JS on Cent OS - node.js

I am very very new to React JS and have tried to install it on my VPS server that is running Cent OS.
Node.js seems to be working,
I have build a React project using the following code as a root level user on SSH:
npx create-react-app my-react-project
cd my-react-project
npm start
but when trying to view in browser I get a blank page (instead of react js default template)?
I see many people install this locally but I haven't found any examples on a hosted VPS, is this something I am doing wrong?
Any help would be much appreciated, thanks!

if you have ssh access to your VPS, the rest is pretty the same as your local environment.
You can copy/paste your project to your CentOS host and use the following commands in order to run it:
cd your_project_folder_which_includes_package_json_file
npm install
npm start
Also, if you are using this server as a production host, You should consider getting a production build of your React app on your local env by running npm run build and then publishing the build folder on your server and serving it using a static file server or using a reverse-proxy such as Nginx as a static server.
Actually this page in React documentation does a good job in explaining the details of deploying a React app, I encourage you to take a look at it.

Related

Running Vue JS project in Docker

I have already built a few VueJs applications for myself. Now I am working with a team. One backend and me frontend.
Now I'm wondering how do I include the environment in the repository. Until today I always had node on my local machine. With nvm I could also jump between versions on the local machine. But now I want future colleagues who will develop the app to have the same environment. So work with the same node and npm version. I thought this could be done with a dockerfile or docker-compose.yml. Then I can log into the container and run the npm run build for example.
Question But how does it work with npm run dev? Do I have access with the browser to the port that is assigned in the container of the Vue app?

How do I host Laravel and Inertiajs (React) app in cPanel?

I built a laravel with inertiajs App, Now I'm going to deploy my app to some host.
I tried Siteground to deploy it but it doesn't support NPM!
Now I'm trying to do it with cpannel, Here is my file structure:
And I already connect SSH terminal. there is no issue with laravel installation, but when I do npm install I'm getting -bash: npm: command not found
Can you help me with some example please!
In production you don't need to install node modules if you have a production version of your (React app)
i usually use Reactjs in frontend so the process is
yarn build
take the build version of your app and add it to the root of your server
for Laravel
git clone ******
cp .env.example .env
edit the .env data to match your production data
run composer install
run php artisan key:generate
php artisan migrate
point your server to the public folder with symbolic link for example
your app should now be live.

How to deploy the Fluid server?

I'm using the Fluid draft-js example here:
https://github.com/microsoft/FluidExamples/tree/main/draft-js
I know I can run the app locally by just running npm start or just the server by using npm start:server
But how can I deploy this app (server) to a production environment? (I'm sorry if this is a stupid question). Should I just upload the repository to a node environment and run the commands? Should I try to make a docker image?
Any ideas?

reactjs app not run after serve and start

I just installed node.js on my centos 7 server, then install react
it successfully created my new react app, after that, I run:
npm start
and or serve -s build
but none of these run in my browser.
This site can’t be reached
how can I solve this?
If you have sever inside can you try with start debugging of your application
Stop npm, if you're using yarn
Start the project with command above, inside your project home folder
yarn start
Take some time to learn commands below:

how to host angular and node js project on the shared hosting (cpanel or plesk)?

I have two different shared hosting on GoDaddy server (cPanel and Plesk odin), I want to host my NodeJS project there.
You CAN do this.
Most tutorials have you downloading node + npm through the command line... and since you cannot use sudo in terminal on a shared GoDaddy server you have to install nvm to install npm and node.
But really, you only need a single file from the Node.js package to get a server running. It is much easier to download the package, and manually add the one file to cPanel.
Follow this tutorial for the most simple method of running a Node.js server on GoDaddy hosting.
You can't host Node project on cpanel. You will need a node server for that. Cpanel does not come with node installed, neither it could be Installed. You can check with aws or blueocean for that.

Resources