I am trying to deploy a next.js v16 app to Elastic Beanstalk using this action. Here's a summary of my pipeline.
- Run
npm install to install dependencies
- Run the
next build command to build the next.js app
- Use the aws-elasticbeanstalk-deploy action to deploy to elastic beanstalk environment
The package is deployed to the server, but the .next/node_modules directory is missing from the deployment.
I tried adding the following to the .ebignore. The .next directory is there but the .next/node_modules directory is still missing in the deployed app.
// .ebignore
## Ensure that the .next directory is NOT ignored!
!.next
!.next/node_modules
Is there a way to force this directory to be included in the deployment package?
Manual zip package creation
I have also tried manually creating a zip of the build. This includes the .next/node_modules directory, but the files within the .next/node_modules directory are symlinks to the node_modules directory.
It seems that the deployment process first uses chown to change the permissions, but this fails as the files are symlinks and this runs before npm install is run on the EC2 instance and the destination of the symlink doesn't yet exist.
Is there a way of running npm install before the permissions are changed?
Thanks.
I am trying to deploy a next.js v16 app to Elastic Beanstalk using this action. Here's a summary of my pipeline.
npm installto install dependenciesnext buildcommand to build the next.js appThe package is deployed to the server, but the
.next/node_modulesdirectory is missing from the deployment.I tried adding the following to the
.ebignore. The.nextdirectory is there but the.next/node_modulesdirectory is still missing in the deployed app.Is there a way to force this directory to be included in the deployment package?
Manual zip package creation
I have also tried manually creating a zip of the build. This includes the
.next/node_modulesdirectory, but the files within the.next/node_modulesdirectory are symlinks to thenode_modulesdirectory.It seems that the deployment process first uses
chownto change the permissions, but this fails as the files are symlinks and this runs beforenpm installis run on the EC2 instance and the destination of the symlink doesn't yet exist.Is there a way of running
npm installbefore the permissions are changed?Thanks.