Pages Build Fails to Compile

For Workes & Pages, what is the name of the domain?

personal

What is the error message?

16:46:10.476 Failed to compile. 16:46:10.476 16:46:10.476 Module not found: Error: Can’t resolve ‘App.js’ in ‘/opt/buildhome/repo/src’

What is the issue or error you’re encountering

Failed Compile and Build

What steps have you taken to resolve the issue?

I can build the same code locally. Then, when I don’t ask Cloudflare to run the build - the deployment works by pointing to the build/ directory.

What are the steps to reproduce the issue?

  1. Create a basic React App with 2 files under src/ viz. index.js and App.js
  2. import App from './App.js'; inside index.js

Screenshot of the error

The error “Module not found: Can’t resolve ‘App.js’” occurs when your file path or import statement is incorrect. To fix this:

  1. Check Case Sensitivity: Ensure App.js matches the exact case.
  2. Verify File Path: Confirm App.js exists in the /src directory and is imported correctly in index.js:

import App from ‘./App’;

  1. Fix Cloudflare Build: If local builds work, deploy pre-built files (npm run build) instead of relying on Cloudflare to build.

For more detailed guidance and troubleshooting tips, please visit The Kaizen Global, which offers solutions and best practices for web development and deployment issues.

  1. Case Sensitivity is perfect. File name App.js and import App from 'App.js';
  2. File path is perfect too. Both App.js and index.js are located in the same directory under src/
  3. I eventually have to rely on using pre-built files but I want to know why Cloudflare build does not work. I don’t have an answer to that yet.

^ Above

Import statement is import App from './App.js';