无法创建 Sveltekit 应用程序 - ERR_TTY_INIT_FAILED,uv_tty_init 返回 EBADF(坏文件描述符)

11
当我运行推荐的$ npm create svelte@latest myapp时,我会收到以下错误:
 Welcome to SvelteKit!
node:internal/errors:490
    ErrorCaptureStackTrace(err);
    ^

SystemError [ERR_TTY_INIT_FAILED]: TTY initialization failed: uv_tty_init returned EBADF (bad file descriptor)
    at new SystemError (node:internal/errors:250:5)
    at new NodeError (node:internal/errors:361:7)
    at new WriteStream (node:tty:93:11)
    at ED.prompt (file:///C:/Users/Skylan/AppData/Local/npm-cache/_npx/50a6160ffc29bafc/node_modules/@clack/core/dist/index.mjs:9:693)
    at Module.ee (file:///C:/Users/Skylan/AppData/Local/npm-cache/_npx/50a6160ffc29bafc/node_modules/@clack/prompts/dist/index.mjs:28:7)
    at template (file:///C:/Users/Skylan/AppData/Local/npm-cache/_npx/50a6160ffc29bafc/node_modules/create-svelte/bin.js:48:6)
    at Module.$e (file:///C:/Users/Skylan/AppData/Local/npm-cache/_npx/50a6160ffc29bafc/node_modules/@clack/prompts/dist/index.mjs:80:345)
    at file:///C:/Users/Skylan/AppData/Local/npm-cache/_npx/50a6160ffc29bafc/node_modules/create-svelte/bin.js:45:25
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25) {
  code: 'ERR_TTY_INIT_FAILED',
  info: {
    errno: -4083,
    code: 'EBADF',
    message: 'bad file descriptor',
    syscall: 'uv_tty_init'
  },
  errno: [Getter/Setter],
  syscall: [Getter/Setter]
}

完整日志

看起来错误发生在创建之后?

34 http fetch GET 200 https://registry.npmjs.org/create-svelte 144ms (cache revalidated)
35 timing arborist:ctor Completed in 0ms
36 timing arborist:ctor Completed in 1ms
37 timing command:create Completed in 299ms
38 verbose stack Error: command failed
38 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:53:27)
38 verbose stack     at ChildProcess.emit (node:events:513:28)
38 verbose stack     at maybeClose (node:internal/child_process:1091:16)
38 verbose stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)

我尝试过更新/重新安装node,但并没有找到任何处理npm create svelte的谷歌或答案。


3
我在MINGW64中使用它时也遇到了这个问题。如果在VSCode终端中运行它,则可以正常工作。有许多精美的提示,所以可能与此有关。 - Simon
2个回答

15
我之前在使用 Git Bash 终端时也遇到了这个错误,后来我改用了 Vscode 终端(也是 bash),然后问题就解决了。虽然我不知道为什么,但它确实起作用了。

1
我曾经遇到过完全相同的问题。 - henrykodev
更换终端对我也解决了这个问题,我之前使用的是Git Bash,然后切换到Windows PowerShell后它就完美地工作了。 - liquid_snake
1
更换终端对我来说也解决了这个问题,我之前使用的是git bash,然后切换到Windows PowerShell后,一切都运行得非常顺利。 - liquid_snake

0

我认为这可能与svelte@latest有关

我运行了npm create svelte@1.0.0 myapp,看起来它将创建一个项目,尽管它似乎很不稳定


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接