Open
Description
💬 Are the Getting Started docs updated?
I'm in the Getting Started section of the fastify docs: https://fastify.dev/docs/latest/Guides/Getting-Started/ in the "Your first server" section. I'm just copy pasting the code provided to get our first server running, here's my code:
// this version does not work
const fastify = require('fastify')({
logger: true
})
// Declare a route
fastify.get('/', function (request, reply) {
reply.send({ hello: 'world' })
})
// Run the server!
fastify.listen({ port: 3000 }, function (err, address) {
if (err) {
fastify.log.error(err)
process.exit(1)
}
console.log(`Server is now listening on ${address}`)
})
// // this version does work
// module.exports = async (fastify, opts) => {
// fastify.get("/", (req, reply) => {
// reply.send('hi module.exports')
// })
// }
I get this error when trying the CommonJS, ES6, and async await versions that were listed in the docs. I'm new to Fastify so I'm unsure what this error means.
But, I was able to find a working version, I was just curious why the ones listed in the docs weren't working for me.
Your Environment
- node version: 20
- fastify version: >=5.0.0
- os: Mac