0

So I obviously can't access localhost:3000 on my server, so I wanted to test it via the ip address with subfolders e.g. (192.0.1.168/reactjs). I've run npm run build and I've gone into the build folder, but it displays an empty page.

Am I missing something?

2
  • How do you serve the index.html file? Commented Dec 21, 2016 at 10:48
  • @OleBläsing That's what I'm trying to figure out. I can get angular 2 to run fine (and easily enough). After running npm run build the index.html is in the build folder. But I have no idea how to serve it. I've even changed the homepage option... unless I've done that incorrectly. Not to mention the index.html comes up as blank. Commented Dec 21, 2016 at 10:56

2 Answers 2

2

npm run build compiles your source files into a minified version of your app. This version can be found inside your /build directory.

If you want to serve this compiled version, you need to setup a webserver. Most common around are "Apache" and "nginx". Configure your webserver to use your /build directory as the root directory.

For configuration advices of your webserver you should read the documentation of the choosen one.

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

4 Comments

I'm using apache, I'm accessing the build directory directly e.g. 192.0.1.168/reactjs/build but it's showing up as blank oddly.
Would you know how to change the build location?
You shouldn't change your homepage config for serving purposes. You should change configuration of your Apache to use build as the root directory. You can configure virtual hosts to host multiple projects on one server.
I'll have to look into virtual hosting as I have no idea how to use it. But for now, for development reasons, I'll just keep it as the /build
1

Solved it by adding "homepage": "/reactjs/build", to package.json. Didn't work before as I didn't put build in it as well.

So the next question is, how do I change the build location, so that I can access it via www.website.com/reactjs rather than www.website.com/reactjs/build.

Comments

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.