Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore me. This is a low-level boot problem #2886

Closed
4 tasks done
hanwu1314 opened this issue Aug 31, 2023 · 1 comment
Closed
4 tasks done

Ignore me. This is a low-level boot problem #2886

hanwu1314 opened this issue Aug 31, 2023 · 1 comment
Labels
bug: pending triage Maybe a bug, waiting for confirmation

Comments

@hanwu1314
Copy link

Describe the bug

I used the document boot method and neither npm nor pnpm could run the docs:dev command properly

X [ERROR] "vitepress" resolved to an ESM file. ESM file cannot be loaded by `require`. See http://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details. [plugin externalize-deps]

    node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild/lib/main.js:1373:27:
      1373 │         let result = await callback({
           ╵                            ^

    at file:///F:/myVitepressBlog/hanwuBlog/node_modules/.pnpm/vite@4.4.9_@types+node@18.17.5/node_modules/vite/dist/node/chunks/dep-df561101.js:66190:35
    at requestCallbacks.on-resolve (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:1373:28)
    at handleRequest (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:729:19)
    at handleIncomingPacket (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:755:7)      
    at Socket.readFromStdout (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:679:7)     
    at Socket.emit (node:events:514:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

  This error came from the "onResolve" callback registered here:

    node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild/lib/main.js:1292:20:
      1292 │       let promise = setup({
           ╵                     ^

    at setup (file:///F:/myVitepressBlog/hanwuBlog/node_modules/.pnpm/vite@4.4.9_@types+node@18.17.5/node_modules/vite/dist/node/chunks/dep-df561101.js:66158:27)
    at handlePlugins (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:1292:21)
    at buildOrContextImpl (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:978:5)        
    at Object.buildOrContext (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:786:5)     
    at F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:2177:15
    at new Promise (<anonymous>)
    at Object.build (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:2176:25)
    at build (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:2025:51)
    at bundleConfigFile (file:///F:/myVitepressBlog/hanwuBlog/node_modules/.pnpm/vite@4.4.9_@types+node@18.17.5/node_modules/vite/dist/node/chunks/dep-df561101.js:66109:26)

  The plugin "externalize-deps" was triggered by this import

    docs/.vitepress/config.ts:1:339:
      1 │ ..._import_meta_url = "file:///F:/myVitepressBlog/hanwuBlog/docs/.vitepress/config.ts";import { defineConfig } from 'vitepress'~~~~~~~~~~~ 

failed to load config from F:\myVitepressBlog\hanwuBlog\docs\.vitepress\config.ts
failed to start server. error:
Error: Build failed with 1 error:
node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild/lib/main.js:1373:27: ERROR: [plugin: externalize-deps] "vitepress" resolved to an 
ESM file. ESM file cannot be loaded by `require`. See http://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details.
    at failureErrorWithLog (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:1649:15)     
    at F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:1058:25
    at runOnEndCallbacks (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:1484:45)       
    at buildResponseToResult (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:1056:7)    
    at F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:1085:16
    at responseCallbacks.<computed> (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:703:9)
    at handleIncomingPacket (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:762:9)      
    at Socket.readFromStdout (F:\myVitepressBlog\hanwuBlog\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:679:7)     
    at Socket.emit (node:events:514:28)
    at addChunk (node:internal/streams/readable:324:12)
 ELIFECYCLE  Command failed with exit code 1.

Reproduction

I started by introducing the latest vue
My version of node is v18.17.1

npm create vue@latest
cd vue-projecr
pnpm install

Then start installing vitepress with pnpm

pnpm add -D vitepress
pnpm exec vitepress init
┌   Welcome to VitePress! 
│
◇  Where should VitePress initialize the config?
│  ./docs
│
◇  Site title:
│  My Awesome Project
│
◇  Site description:
│  A VitePress Site
│
◇  Theme:
│  Default Theme
│
◇  Use TypeScript for config and theme files?
│  Yes
│
◇  Add VitePress npm scripts to package.json?
│  Yes
│
└  Done! Now run npm run docs:dev and start writing.

When I run

pnpm run docs:dev 

It doesn't work properly
I don't know how to solve it

Expected behavior

I hope it starts up properly, just like vue

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
    Memory: 5.94 GB / 15.86 GB
  Binaries:
    Node: 18.17.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 9.6.7 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.6.12 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (116.0.1938.62)    
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    vitepress: 1.0.0-rc.10 => 1.0.0-rc.10

Additional context

No response

Validations

@hanwu1314 hanwu1314 added the bug: pending triage Maybe a bug, waiting for confirmation label Aug 31, 2023
@brc-dd
Copy link
Member

brc-dd commented Aug 31, 2023

Rename .vitepress/config.ts to .vitepress/config.mts, or add "type": "module" to your package.json. vitepress init should already have done that though 👀

@hanwu1314 hanwu1314 changed the title I can't start properly Ignore me. This is a low-level boot problem Aug 31, 2023
@brc-dd brc-dd closed this as completed in 195ebe9 Aug 31, 2023
tangllty added a commit to tangllty/tang-docs that referenced this issue Sep 5, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: pending triage Maybe a bug, waiting for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants