facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.73k stars 26.85k forks source link

Failed to load resource: net::ERR_FILE_NOT_FOUND after build. #6369

Closed tinypell3ts closed 5 years ago

tinypell3ts commented 5 years ago

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes, npm version : 6.4.1

Environment

System: OS: macOS 10.14.2 CPU: x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz Binaries: Node: 10.15.0 - /usr/local/bin/node npm: 6.4.1 - /usr/local/bin/npm Browsers: Chrome: 72.0.3626.96 Safari: 12.0.2 npmPackages: react: ^16.8.1 => 16.8.1 react-dom: ^16.8.1 => 16.8.1 react-scripts: 2.1.3 => 2.1.3 npmGlobalPackages: create-react-app: 2.1.3

Steps to Reproduce

  1. create-react-app newapp
  2. npm run build
  3. Open /build/index.html in chrome web browser

Expected Behavior

The react app to work correctly in production.

Actual Behavior

The page is blank and multiple Failed to load resource: net::ERR_FILE_NOT_FOUND errors in console log. It works fine in development, not production. I have used create-react-app several times and have never experienced this issue.

screenshot 2019-02-09 at 00 45 32

Reproducible Demo

use create-react-app and build something.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

mmstarz commented 5 years ago

try doing this (works for Windows, i don't have linux to test): step1: at your package.json add "homepage": "." step2: npm run build step3: cd build folder (or just copy(cut) it somwhere and go inside via your IDE ) step4: npm init step5: edit package.json: ... "main": "app.js", "scripts": { "start": "node app.js", } ... step6: npm install --save express step7: create app.js: const express = require('express'); const path = require('path'); const app = express(); app.use(express.static(path.join(dirname, 'build'))); app.get('/', function(req, res) { res.sendFile(path.join(dirname, 'build', 'index.html')); }); app.listen(9000); step8: create start.bat file set BROWSER=chrome.exe start %BROWSER% -new-tab "http://localhost:9000" node app.js step9: open your build folder in OS double click on start.bat

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

stale[bot] commented 5 years ago

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.