docs-ko icon indicating copy to clipboard operation
docs-ko copied to clipboard

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

Open github-actions[bot] opened this issue 3 years ago • 0 comments

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


+++ b/docs/guide/ssr.md
@@ -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()

github-actions[bot] avatar Jul 18 '22 00:07 github-actions[bot]