Closed weijie0 closed 1 year ago
I have encountered the same issue as you and I noticed that you have submitted this issue. May I ask if it has been resolved?
[plugin:vite-plugin-vitepress-auto-sidebar] ENOENT: no such file or directory, scandir 'D:\work\h7ml\github\h7ml\code\docs'
/@siteData
at Object.readdirSync (node:fs:1451:3)
I found that the plugin generates the path incorrectly. My path is "code\src" but it is looking for "code\docs". The main issue is that I don't even have a "docs" directory.
I think that in this line of code: https://github.com/QC2168/vite-plugin-vitepress-auto-sidebar/blob/main/src/index.ts#L142, you should retrieve the path from the "vitepress dev [path]" command in the "dev" script of the example's package.json file: https://github.com/QC2168/vite-plugin-vitepress-auto-sidebar/blob/main/example/package.json#L7. Instead of hardcoding the path as "docs", you should dynamically retrieve it from the command.
build error
Run pnpm build
> codeinterviewpro@1.0.0 build /home/runner/work/codeinterviewpro/codeinterviewpro
> vitepress build docs
vitepress v1.0.0-alpha.60
- building client + server bundles...
[auto-sidebar] injected sidebar data successfully
[vite:build-import-analysis] Cannot destructure property 'line' of 'locate(...)' as it is undefined.
file: /@siteData
✖ building client + server bundles...
build error:
TypeError: Cannot destructure property 'line' of 'locate(...)' as it is undefined.
at augmentCodeLocation (file:///home/runner/work/codeinterviewpro/codeinterviewpro/node_modules/.pnpm/rollup@3.1[9](https://github.com/h7ml/codeinterviewpro/actions/runs/4428076744/jobs/7766630834#step:6:10).1/node_modules/rollup/dist/es/shared/node-entry.js:2137:17)
at Object.error (file:///home/runner/work/codeinterviewpro/codeinterviewpro/node_modules/.pnpm/rollup@3.19.1/node_modules/rollup/dist/es/shared/node-entry.js:23382:25)
at Object.transform (file:///home/runner/work/codeinterviewpro/codeinterviewpro/node_modules/.pnpm/vite@4.1.4_sass@1.59.3/node_modules/vite/dist/node/chunks/dep-ca2[12](https://github.com/h7ml/codeinterviewpro/actions/runs/4428076744/jobs/7766630834#step:6:13)28b.js:43545:[22](https://github.com/h7ml/codeinterviewpro/actions/runs/4428076744/jobs/7766630834#step:6:23))
ELIFECYCLE Command failed with exit code 1.
Error: Process completed with exit code 1.```
I have encountered the same issue as you and I noticed that you have submitted this issue. May I ask if it has been resolved?
[plugin:vite-plugin-vitepress-auto-sidebar] ENOENT: no such file or directory, scandir 'D:\work\h7ml\github\h7ml\code\docs' /@siteData at Object.readdirSync (node:fs:1451:3)
the plugin allows users to provide customization options
, if your docs folder name is not docs, you need to provide the path parameter
in package.json
"scripts": {
"dev": "vitepress dev src",
"build": "vitepress build src"
}
in.vitepress/config.js
import AutoSidebar from "vite-plugin-vitepress-auto-sidebar";
export default {
lang: "en-US",
title: "VitePress",
description: "Vite & Vue powered static site generator.",
vite: {
plugins: [AutoSidebar({
path:'/src',
})],
},
themeConfig: {
nav: [{ text: "note", link: "/note/index" }],
},
};
if (/\/@siteData/.test(id)) {
这行代码报错