I'm trying to deploy my Next.js application on AWS Amplify, but I keep running into an error during the build process. The error message indicates that a package.json file is not found, even though the file is present in my project directory. After struggling with the issue, I decided to try deploying a simpler React.js application, but I'm encountering the exact same error.
Here’s what I’ve done so far:
For the Next.js Application:
I followed the usual deployment steps by connecting my GitHub repository to AWS Amplify. My build configuration includes a preBuild step where I attempt to install dependencies using pnpm (since I'm using pnpm instead of npm). The error I'm seeing is: ERR_PNPM_NO_PKG_MANIFEST No package.json found in /codebuild/output/src1064057875/src/my-app. I checked that the package.json file is indeed in the correct directory, so I’m not sure why it’s not being found during the build process.
For the React.js Application:
I went through a similar process, but the error persists. Even though this is a simpler project, I’m encountering the same No package.json found error.
2024-08-10T11:20:48.923Z [INFO]: Cloning into 'React-Test'...
2024-08-10T11:20:48.924Z [INFO]: # Checking for Git submodules at: /codebuild/output/src1136899761/src/React-Test/.gitmodules
2024-08-10T11:20:48.929Z [INFO]: # Retrieving environment cache...
2024-08-10T11:20:48.969Z [WARNING]: ! Unable to write cache: {"code":"ERR_BAD_REQUEST","message":"Request failed with status code 404"})}
2024-08-10T11:20:48.969Z [INFO]: ---- Setting Up SSM Secrets ----
2024-08-10T11:20:48.969Z [INFO]: SSM params {"Path":"/amplify/dlz7sqplffptg/main/","WithDecryption":true}
2024-08-10T11:20:49.024Z [WARNING]: !Failed to set up process.env.secrets
2024-08-10T11:20:49.940Z [INFO]: No live updates for this build run
2024-08-10T11:20:49.944Z [INFO]: # Retrieving cache...
2024-08-10T11:20:49.994Z [INFO]: # Retrieved cache
2024-08-10T11:20:53.726Z [INFO]: ## Starting Backend Build
## Checking for associated backend environment...
## No backend environment association found, continuing...
## Completed Backend Build
2024-08-10T11:20:53.731Z [INFO]: {"backendDuration": 0}
## Starting Frontend Build
# Starting phase: build
# Executing command: npm run build
2024-08-10T11:21:06.367Z [WARNING]: npm
2024-08-10T11:21:06.376Z [WARNING]: ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /codebuild/output/src1136899761/src/React-Test/package.json
npm ERR! errno -2
npm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/codebuild/output/src1136899761/src/React-Test/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-08-10T11_21_04_220Z-debug-0.log
2024-08-10T11:21:06.457Z [ERROR]: !!! Build failed
2024-08-10T11:21:06.457Z [ERROR]: !!! Error: Command failed with exit code 254
2024-08-10T11:21:06.458Z [INFO]: # Starting environment caching...
2024-08-10T11:21:06.458Z [INFO]: # Environment caching completed
I just want to deploy my nextjs and reactjs application on aws amplify if not then can you provide any other reference to deploy my application on aws but not EC2