Skip to content
Issues Deploying React Builds
wolfcon2023
OP

2 years 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 [email protected]: Glob versions prior to v9 are no longer supported

npm warn deprecated [email protected]: Use your platform's native DOMException instead

npm warn deprecated [email protected]: Use your platform's native atob() and btoa() methods instead

npm warn deprecated [email protected]: This SVGO version is no longer supported. Upgrade to v2.x.x.

npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/object-schema instead

npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/config-array instead

npm warn deprecated @babel/[email protected]: 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/[email protected]: 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/[email protected]: 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/[email protected]: 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/[email protected]: 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 [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.

[email protected] postinstall

npm run build

[email protected] 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 [email protected]

npm notice

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

View Deploy details

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

Solved

6 Replies

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 • almost 2 years ago


wolfcon2023
OP

2 years 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 • almost 2 years 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 • almost 2 years ago


wolfcon2023
OP

2 years 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 • almost 2 years ago


wolfcon2023
OP

2 years ago

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


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


Status changed to Awaiting User Response Railway • almost 2 years ago


Status changed to Solved christian • almost 2 years ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...