2

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 ?

1
  • once builded you can host it as static website What problem you are facing when try to host build in your particular server? Commented Mar 27, 2022 at 7:20

3 Answers 3

6

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)

Sign up to request clarification or add additional context in comments.

1 Comment

this is actually good answer
2

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.

1 Comment

I will go over these links thanks @Peter
2

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.

6 Comments

yes i have used few things like react-scripts, materials-ui, etc., inside my webpage,. and i need to host it in IIS.. can you please let me know how to get those output files ?
And, when i produce the build package with npm run build, i was told that since the build packages have node dependencies, it cant be hosted in IIS. Is this correct ?
Is there anything in your package that uses the Node server itself? If not, npm run build will output static files that you can host with IIS.
I am not sure on that.. as far as i know we use npm to install some libraries..is there a way to check whether i am using node server ?
What happens when you just try to load the generated index.html locally in your browser? What errors (if any) appear?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.