Deploying React app to AWS to Amplify : React build fail with "Module not found: Error: Can't resolve './components/...' in '/codebuild/output/src313005

for some time, I have been wrapping my head around an error preventing me from deploying my react app to AWS Amplify. The compiler seems not to be able to resolve a component during the build phase. I keep getting the following error Module not found: Error: Can't resolve './components/...' in '/codebuild/output/src313005886/src/client-portal/src; please see the attached error output bellow.

enter image description here

Here is how the file is imported:

import AdminCreateEvaluation from "./components/evaluationgeneratorform";

I have tried several solutions, including renaming my files, but the build won’t just compile;
Any help will be appreciated.

Thank you.

1 Like

Would need to see more code, how it’s being built, see the file structure, ideally a minimal reproduction, or the project github: it’s impossible to tell from what you’ve posted. Create react app’s react-scripts CLI tools are trying to run and it can’t resolve that specific file, doesn’t look anything to do with amplify’s CLI tools. What happens if you run npm build (or yarn build if you’re using yarn instead of npm)?

The code builds perfectly well locally.
Here is the file structure

What are the build commands codebuild is using? ie what does the .buildspec file look like? And what version of Node is it using, if it’s the default then change it to v14 at least

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.