Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,25 @@ function doSomething() {

**Otherwise:** Requires are run synchronously by Node.js. If they are called from within a function, it may block other requests from being handled at a more critical time. Also, if a required module or any of its dependencies throw an error and crash the server, it is best to find out about it as soon as possible, which might not be the case if that module is required from within a function

### Example

❌ Bad:

```js
function getUserById(id) {
const db = require('./db'); // required inside function
return db.findUser(id);
}
```
✅ good:

```js
const db = require('./db'); // required at top
function getUserById(id) {
return db.findUser(id);
}
```

<br/><br/>

## ![✔] 3.9 Set an explicit entry point to a module/folder
Expand Down