fastify / fastify/help

Are the Getting Started docs updated?

Open
#1,078 3 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
No language data
Stars
68
Forks
8
Avg merge
11h 2m
Merged PRs (30d)
2

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:

```js
// 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.
Image

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.