docs: __dirname is not available in ES modules (#9151)

This commit is contained in:
li.li 2022-07-17 13:02:25 +08:00 committed by GitHub
parent 344642ad63
commit cc980b0944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,8 +64,11 @@ When building an SSR app, you likely want to have full control over your main se
```js{17-19}
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
import express from 'express'
import {createServer as createViteServer} from 'vite'
import { createServer as createViteServer } from 'vite'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
async function createServer() {
const app = express()