Running Strapi v4 on AWS Beanstalk

System Information
  • Strapi Version: 4.1.9
  • Operating System: Amazon Linux x64 with Node 14 (t3.small Instance type)
  • Database: SQLite
  • Node Version: 14.19.1
  • NPM Version: 6.14.16
  • Yarn Version: n/a

Dear community,

I want to deploy Strapi on Amazon AWS Beanstalk, following this article:

So my pipeline is working fine, I can see in its logfiles that my strapi v4 builds nice and finally gets deployed on the EC2 instance that Beanstalk creates. So far so good. But then, I’m stuck.
The local build on the EC2 instance fails, manual start will return

-sh-4.2$ npm run start

> my-project@0.1.0 start /var/app/current
> strapi start

  throw err;

Error: Cannot find module '../package.json'
Require stack:
- /var/app/current/node_modules/.bin/strapi
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/var/app/current/node_modules/.bin/strapi:13:21)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) {
  requireStack: [ '/var/app/current/node_modules/.bin/strapi' ]
npm ERR! errno 1
npm ERR! my-project@0.1.0 start: `strapi start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the my-project@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/webapp/.npm/_logs/2022-05-09T10_29_45_358Z-debug.log

my file structure is as following

├── build
├── buildspec.yml
├── .cache
├── config
├── database
├── .ebignore
├── .editorconfig
├── .env
├── .env.example
├── .eslintignore
├── .eslintrc
├── favicon.ico
├── .gitignore
├── node_modules
├── .npmrc
├── package.json
├── package-lock.json
├── procfile
├── Procfile
├── public
├── src
├── .strapi-updater.json
└── .tmp

I already tried cleaning all node_modules, package-lock.json, etc, no change.

I’d really apprechiate any ideas and help

Thanks so much in advance



I’m having the same exact issue…
I can’t figure it out for the life of me…

Checked the artifact and every file is exactly where it’s supposed to be, also it both builds and runs locally

Hi team,

I have exactly the same issue. I’ve been upgrading to the latest Strapi version (4.4.3) and try to deploy to AWS Beanstalk (using Node.js 16 runtime env) using AWS Pipelines. The application is not starting up correctly without any noticeable errors in the logs.

Running the app locally works without issues.