SM079
SM079

Reputation: 755

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 ?

Upvotes: 2

Views: 2703

Answers (3)

Jone Polvora
Jone Polvora

Reputation: 2338

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)

Upvotes: 6

Vincent La
Vincent La

Reputation: 504

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.

Upvotes: 2

Peter Hassaballah
Peter Hassaballah

Reputation: 1985

I suggest using Netlify to host your react app easily . Below are some resources that can help you along the way.

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.

Upvotes: 2

Related Questions