Run Express Locally for Elastic Beanstalk¶
Prerequisites¶
- Node.js 18 or later installed.
- A terminal in your project folder.
- npm registry access for installing dependencies.
- Basic familiarity with JavaScript modules and Express.
What You'll Build¶
You will create a minimal Express app that listens on process.env.PORT with a default of 8080, define a start command, and declare a Node engine version in package.json so the app aligns with Elastic Beanstalk Node.js expectations.
flowchart TD
A[npm start] --> B[Node.js process]
B --> C[Express app]
C --> D[listen on process.env.PORT or 8080]
D --> E[Local browser request] Steps¶
-
Initialize a new npm project and install Express.
-
Create
app.jswith an Elastic Beanstalk-compatible port pattern. -
Update
package.jsonscripts and engine constraints. -
Run the application locally.
-
Test with a local request.
Verification¶
- Terminal shows
Server listening on 8080or another value fromPORT. - HTTP request returns a
200response and the example message body. package.jsoncontains bothscripts.startandengines.node.- Source tree is ready for Elastic Beanstalk source bundle packaging.