vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.48k stars 1.86k forks source link

Build failed 构建失败 #1209

Closed Tyh2001 closed 1 year ago

Tyh2001 commented 1 year ago

Describe the bug

在使用 vitepress v1.0.0-alpha.8 版本在构建项目之后打包会抛出异常错误信息,导致打包失败:

经过测试,在 vitepress v1.0.0-alpha.5 以后的版本中都存在这个问题

PS D:\项目-我的\vitepress-demo> pnpm build 

> vitepress-demo@ build D:\项目-我的\vitepress-demo
> vitepress build docs

vitepress v1.0.0-alpha.8
build error:
 Error: EPERM: operation not permitted, symlink 'D:\项目-我的\vitepress-demo\node_modules\.pnpm\vue@3.2.3    at linkVue (file:///D:/%E9%A1%B9%E7%9B%AE-%E6%88%91%E7%9A%84/vitepress-demo/node_modules/.pnpm/vitepress@1.0.0-alpha.8/node_modules/vitepress/dist/node/serve-cd8de79e.js:40713:11)
    at build (file:///D:/%E9%A1%B9%E7%9B%AE-%E6%88%91%E7%9A%84/vitepress-demo/node_modules/.pnpm/vitepress@1.0.0-alpha.8/node_modules/vitepress/dist/node/serve-cd8de79e.js:40646:21)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {  errno: -4048,
  syscall: 'symlink',  code: 'EPERM',
  path: 'D:\\项目-我的\\vitepress-demo\\node_modules\\.pnpm\\vue@3.2.37\\node_modules\\vue',
  dest: 'D:\\项目-我的\\vitepress-demo\\docs\\node_modules\\vue'
}
 ELIFECYCLE  Command failed with exit code 1.

Reproduction

初始化项目

pnpm init

向package.json添加一些脚本

  "scripts": {
    "dev": "vitepress dev docs",
    "build": "vitepress build docs",
    "serve": "vitepress serve docs"
  },
pnpm i vitepress vue

mkdir docs && echo '# Hello VitePress' > docs/index.md

pnpm build

Expected behavior

构建成功

System Info

PS D:\项目-我的\vitepress-demo> pnpm build 

> vitepress-demo@ build D:\项目-我的\vitepress-demo
> vitepress build docs

vitepress v1.0.0-alpha.8
build error:
 Error: EPERM: operation not permitted, symlink 'D:\项目-我的\vitepress-demo\node_modules\.pnpm\vue@3.2.3    at linkVue (file:///D:/%E9%A1%B9%E7%9B%AE-%E6%88%91%E7%9A%84/vitepress-demo/node_modules/.pnpm/vitepress@1.0.0-alpha.8/node_modules/vitepress/dist/node/serve-cd8de79e.js:40713:11)
    at build (file:///D:/%E9%A1%B9%E7%9B%AE-%E6%88%91%E7%9A%84/vitepress-demo/node_modules/.pnpm/vitepress@1.0.0-alpha.8/node_modules/vitepress/dist/node/serve-cd8de79e.js:40646:21)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {  errno: -4048,
  syscall: 'symlink',  code: 'EPERM',
  path: 'D:\\项目-我的\\vitepress-demo\\node_modules\\.pnpm\\vue@3.2.37\\node_modules\\vue',
  dest: 'D:\\项目-我的\\vitepress-demo\\docs\\node_modules\\vue'
}
 ELIFECYCLE  Command failed with exit code 1.

Additional context

09169be6c8894447b745ad751f926d7 0eb22af646e12f7442eba3ce806d02a

Validations

Hacker-C commented 1 year ago

Same problem, but there is no error with yarn or npm

Tyh2001 commented 1 year ago

Same problem, but there is no error with yarn or npm

我使用 npm 、yarn、pnpm 都会这样

Hacker-C commented 1 year ago

Same problem, but there is no error with yarn or npm

我使用 npm 、yarn、pnpm 都会这样

切换为 yarn/npm 之前,node_modules 和 lock 文件删了吗?然后重新 install。

Tyh2001 commented 1 year ago

Same problem, but there is no error with yarn or npm

我使用 npm 、yarn、pnpm 都会这样

切换为 yarn/npm 之前,node_modules 和 lock 文件删了吗?然后重新 install。

全面都删除了,重新安装的

brc-dd commented 1 year ago

Which operating systems are you guys using?

Tyh2001 commented 1 year ago

Which operating systems are you guys using?

windows 11

brc-dd commented 1 year ago

Ah, on Windows you need to enable dev mode to create symlinks without root access.

Tyh2001 commented 1 year ago

Ah, on Windows you need to enable dev mode to create symlinks without root access.

那为什么在 vitepress v1.0.0-alpha.5 版本之前都是可以正常使用的,但是在后续的新版本中都相同问题

Hacker-C commented 1 year ago

Which operating systems are you guys using?

windows 11

My yarn and npm is on the WSL, there is no error with them. But my pnpm is on Windows, so it caused errors. Maybe this is a new bug in this version.

brc-dd commented 1 year ago

那为什么在 vitepress v1.0.0-alpha.5 版本之前都是可以正常使用的,但是在后续的新版本中都相同问题

It was added here https://github.com/vuejs/vitepress/pull/856/commits/3b2d90acf4d3091a784cb7600017c41a3ed3b65e. For now you can consider enabling dev mode. We are looking for a way to fix this.


My yarn and npm is on the WSL, there is no error with them. But my pnpm is on Windows, so it caused errors. Maybe this is a new bug in this version.

Yeah there won't be any issues inside WSL as it's basically a Linux layer. On macOS and other *nix, this shouldn't cause any issue as well.

free-heart commented 1 year ago

临时解决方案:以管理员权限运行 cmd,但是 build 之后,会在docs文件夹下面生成 node_modules 文件夹,下次再 build 的时候,需要先删除 docs文件夹下面的 node_modules 文件夹

Tyh2001 commented 1 year ago

临时解决方案:以管理员权限运行 cmd,但是 build 之后,会在docs文件夹下面生成 node_modules 文件夹,下次再 build 的时候,需要先删除 docs文件夹下面的 node_modules 文件夹

哦哦,我尝试使用管理员身份运行 cmd 打包成功了,是预期的结果。

但是我认为这仍然是个问题

less-js commented 1 year ago

Which operating systems are you guys using?

macOS Monterey 12.5.1 也这样的,npm、yarn都不行

less-js commented 1 year ago

mac 下使用 sudo 操作也不行哦