Issues Deploying React Builds
wolfcon2023
PROOP

10 months ago

I keep encountering the issue below during my react app builds, although the index.html file exists. Is there a solution for this, as my build and deploys work locally, but not in Railway? This is a major impediment that's hindering the delivery of critical code for my customer.

process "/bin/sh -c npm install" did not complete successfully: exit code: 1

View in context
Truncated to 21 lines

npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported

npm warn deprecated domexception@2.0.1: Use your platform's native DOMException instead

npm warn deprecated abab@2.0.6: Use your platform's native atob() and btoa() methods instead

npm warn deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.

npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead

npm warn deprecated @humanwhocodes/config-array@0.13.0: Use @eslint/config-array instead

npm warn deprecated @babel/plugin-proposal-optional-chaining@7.21.0: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.

npm warn deprecated @babel/plugin-proposal-numeric-separator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.

npm warn deprecated @babel/plugin-proposal-private-methods@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-methods instead.

npm warn deprecated @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.

npm warn deprecated @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.

npm warn deprecated eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.

wolf-backoffice-apps@1.0.0 postinstall
npm run build

wolf-backoffice-apps@1.0.0 build
react-scripts build

Could not find a required file.

Name: index.html

Searched in: /app/public

npm error code 1
npm error path /app
npm error command failed

npm error command sh -c npm run build

npm notice
npm notice New major version of npm available! 10.8.2 -> 11.1.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.1.0
npm notice To update run: npm install -g npm@11.1.0
npm notice

npm error A complete log of this run can be found in: /root/.npm/logs/2025-02-12T183240207Z-debug-0.log

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

Solved

6 Replies

christian
EMPLOYEE

10 months ago

Can you confirm that your index.html file is located in the /app/public directory as expected by the build process?


Status changed to Awaiting User Response Railway 10 months ago


wolfcon2023
PROOP

10 months ago

Yes it is (below).

jchri@WCGLLC MINGW64 ~/Dropbox/Wolf Consulting Group/WCG/Development/GitHub/wolf-backoffice-apps/build (main)

$ ls -al

total 37

drwxr-xr-x 1 jchri 197609 0 Feb 12 16:03 ./

drwxr-xr-x 1 jchri 197609 0 Feb 12 10:59 ../

-rw-r--r-- 1 jchri 197609 21 Feb 11 15:15 _redirects

-rw-r--r-- 1 jchri 197609 517 Feb 12 16:03 asset-manifest.json

-rw-r--r-- 1 jchri 197609 3870 Feb 11 15:15 favicon.ico

-rw-r--r-- 1 jchri 197609 350 Feb 12 16:03 index.html

-rw-r--r-- 1 jchri 197609 5347 Feb 11 15:15 logo192.png

-rw-r--r-- 1 jchri 197609 9664 Feb 11 15:15 logo512.png

-rw-r--r-- 1 jchri 197609 492 Feb 11 15:15 manifest.json

-rw-r--r-- 1 jchri 197609 67 Feb 11 15:15 robots.txt

drwxr-xr-x 1 jchri 197609 0 Feb 12 16:03 static/

jchri@WCGLLC MINGW64 ~/Dropbox/Wolf Consulting Group/WCG/Development/GitHub/wolf-backoffice-apps/build (main)


Status changed to Awaiting Railway Response Railway 10 months ago


christian
EMPLOYEE

10 months ago

From the looks of it, the directory you shared is not named <project_root>/app/public. Could you please verify?


Status changed to Awaiting User Response Railway 10 months ago


wolfcon2023
PROOP

10 months ago

Yes, I can confirm that my index.html file is generated correctly during the build process and exists in the build/ directory as expected by React. However, the build process expects it in /app/public/, but React’s build system places it in /app/build/. By default, react-scripts build places the index.html inside the /app/build directory, not /app/public. It looks like the deployment process on Railway is expecting it in /app/public, which is likely causing the issue.

What I Have Tried So Far:

1. Verified that index.html is present inside /app/build/ locally after running npm run build.

Updated my Dockerfile and server.js to serve from /app/build/ instead of /app/public/:

Dockerfile: CMD ["npx", "serve", "-s", "build"]

server.js: app.use(express.static(path.join(__dirname, "build")));

2. Checked the logs using railway logs --service wolf-backoffice-apps, and I see:

Error: ENOENT: no such file or directory, stat '/app/public/index.html'

Potential Fixes I See:

Either adjust Railway’s deployment settings to look for /app/build/index.html OR

Modify the React build command to move index.html into /app/public/:

"scripts": {

"build": "react-scripts build && mv build public"

}

Would you be able to confirm if there’s a way to configure Railway to expect the build output in /app/build/ instead of /app/public/? Or is there another recommended approach for serving the React build correctly in this deployment environment?


Status changed to Awaiting Railway Response Railway 10 months ago


wolfcon2023
PROOP

10 months ago

We were able to resolve by eliminating the use of Docker.


christian
EMPLOYEE

10 months ago

Thank you for the update. We'll mark this thread as solved.


Status changed to Awaiting User Response Railway 10 months ago


Status changed to Solved christian 10 months ago


Loading...