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

执行 pnpm run dev 报错(Error: spawn pnpm ENOENT) #3

Open
gouxinjie opened this issue Sep 6, 2024 · 1 comment
Open

执行 pnpm run dev 报错(Error: spawn pnpm ENOENT) #3

gouxinjie opened this issue Sep 6, 2024 · 1 comment

Comments

@gouxinjie
Copy link

报错如下:
PS C:\A-Xinjie-Code\mp\ys-mp\ky-genshin-map> npm run dev

dev
esbuild build.ts --format=cjs | node - dev

node:events:497
throw er; // Unhandled 'error' event
^

Error: spawn pnpm ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:286:19)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node:internal/child_process:292:12)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn pnpm',
path: 'pnpm',
spawnargs: [ 'run', 'uno', '-w' ]
}

Node.js v21.7.0

截图如下:
mp

@gouxinjie
Copy link
Author

这个问题找到报错的原因了,因为windows系统不能直接识别 pnpm或npm 命令,所以build.ts的 这一行会报错
spawn("pnpm", ["run", "uno", "-w"], { stdio: "inherit" });

有两种改法:
spawn(process.platform === "win32" ? "pnpm.cmd" : "pnpm", ["run", "uno", "-w"], { stdio: "inherit" });
或者
spawn("cmd", ["/c", "pnpm", "run", "uno", "-w"], { stdio: "inherit" });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant