curl express hello world

The official express.js hello world example may crash on certain deployments that rely on a certain PORT.

Make sure you use the PORT set on process.env if it is set.

const PORT = process.env.PORT || 3000

Complete example (code):

const express = require('express')
const app = express()
const PORT = process.env.PORT || 3000
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(PORT, () => console.log(`Example app listening on port ${PORT}!`))

Expert level: How to curl this into an index.js file

I’ve created a link that links to the raw version of a file called “hello-world” in my repo “code

How to: curl it and create an index.js file

curl -L > index.js


More about curl