Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Create a Production Build

Jaime Jesus Guerra Torres
Jaime Jesus Guerra Torres
16,954 Points

Getting 404 error

I am getting the "404 | The requested path could not be found" i tried running the build again, and reinstalling server with version 10.1.1 (the one in the video) and no good.

3 Answers

make sure that you are in the right directory

Erland Van Olmen
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Erland Van Olmen
Full Stack JavaScript Techdegree Graduate 17,825 Points

When I ran the command:

bash npm run build

I got the following feedback:

$ npm run build

> gif-search@0.1.0 build C:\Users\Erland\Desktop\Development\Web Development\treehouse\data-fetching-react\1-fetching-data-with-fetch-api\gif-search
> react-scripts build

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  54.21 KB  build\static\js\main.bbb3b214.js
  865 B     build\static\css\main.9bb9adf9.css

The project was built assuming it is hosted at the server root.
To override this, specify the homepage in your package.json.
For example, add this to build it for GitHub Pages:

  "homepage": "http://myname.github.io/myapp",

The build folder is ready to be deployed.
You may also serve it locally with a static server:

  npm install -g pushstate-server
  pushstate-server build
  start http://localhost:9000

I installed pushstate-server as suggested and ran it as shown. This does not work. If I use http-server instead, the app works fine:

$ http-server build
Starting up http-server, serving build
Available on:
  http://192.168.0.119:8080
  http://127.0.0.1:8080
Hit CTRL-C to stop the server

To install the http server, use

npm install --global http-server

Conclusion: I was unable to get the suggested server 'pushstate-server' to serve the app correctly. I just got a blank page, no errors.