无法创建一个SvelteKit项目。

huangapple go评论80阅读模式
英文:

Can't create a sveltekit project

问题

I'm sorry, but I cannot assist with the translation of the provided content as it includes specific instructions not to translate the code part. If you have any other non-coding related questions or requests, feel free to ask.

英文:

When I run npm create svelte@latest app in my folder I am getting this error.

node:internal/errors:490
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\PC\AppData\Local\npm-cache\_npxa6160ffc29bafc\node_modules\create-svelte\index.js' imported from C:\Users\PC\AppData\Local\npm-cache\_npxa6160ffc29bafc\node_modules\create-svelte\bin.js
    at new NodeError (node:internal/errors:399:5)
    at finalizeResolution (node:internal/modules/esm/resolve:326:11)
    at moduleResolve (node:internal/modules/esm/resolve:945:10)
    at defaultResolve (node:internal/modules/esm/resolve:1153:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
    at link (node:internal/modules/esm/module_job:76:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.16.0
npm ERR! code 1
npm ERR! path C:\Users\PC\Documents\Project Eduards
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c create-svelte app

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\PC\AppData\Local\npm-cache\_logs23-05-07T04_43_14_156Z-debug-0.log

The log looks like this

0 verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
1 info using npm@9.5.1
2 info using node@v18.16.0
3 timing npm:load:whichnode Completed in 2ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 2ms
6 timing config:load:builtin Completed in 2ms
7 timing config:load:cli Completed in 3ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:C:\Users\PC\Documents\Project Eduards\.npmrc Completed in 0ms
10 timing config:load:project Completed in 3ms
11 timing config:load:file:C:\Users\PC\.npmrc Completed in 0ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:C:\Users\PC\AppData\Roaming\npm\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:setEnvs Completed in 1ms
16 timing config:load Completed in 12ms
17 timing npm:load:configload Completed in 14ms
18 timing npm:load:mkdirpcache Completed in 0ms
19 timing npm:load:mkdirplogs Completed in 1ms
20 verbose title npm create svelte@latest app
21 verbose argv "create" "svelte@latest" "app"
22 timing npm:load:setTitle Completed in 1ms
23 timing config:load:flatten Completed in 4ms
24 timing npm:load:display Completed in 8ms
25 verbose logfile logs-max:10 dir:C:\Users\PC\AppData\Local\npm-cache\_logs23-05-07T04_43_14_156Z-
26 verbose logfile C:\Users\PC\AppData\Local\npm-cache\_logs23-05-07T04_43_14_156Z-debug-0.log
27 timing npm:load:logFile Completed in 6ms
28 timing npm:load:timers Completed in 1ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 33ms
31 silly logfile start cleaning logs, removing 2 files
32 timing arborist:ctor Completed in 1ms
33 silly logfile done cleaning log files
34 http fetch GET 200 https://registry.npmjs.org/create-svelte 1229ms (cache revalidated)
35 timing arborist:ctor Completed in 0ms
36 timing arborist:ctor Completed in 0ms
37 timing command:create Completed in 1577ms
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)
39 verbose cwd C:\Users\PC\Documents\Project Eduards
40 verbose Windows_NT 10.0.18363
41 verbose node v18.16.0
42 verbose npm  v9.5.1
43 error code 1
44 error path C:\Users\PC\Documents\Project Eduards
45 error command failed
46 error command C:\Windows\system32\cmd.exe /d /s /c create-svelte app
47 verbose exit 1
48 timing npm Completed in 1674ms
49 verbose code 1
50 error A complete log of this run can be found in:
50 error     C:\Users\PC\AppData\Local\npm-cache\_logs23-05-07T04_43_14_156Z-debug-0.log

I tried reinstalling nodejs and restarting my pc but that did not work.

答案1

得分: 1

可能是npx的缓存安装出了问题。
考虑前往C:\Users\PC\AppData\Local\npm-cache\_npx,删除npx文件夹,然后尝试运行npm create svelte@latest
希望能帮到你。

英文:

It could be an issue with your cache installation of npx.
Consider going to your AppData at 'C:\Users\PC\AppData\Local\npm-cache\_npx' and delete the npx folder and try npm create svelte@latest.
Hope it helps.

huangapple
  • 本文由 发表于 2023年5月7日 12:50:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76192241.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定