astro
astro copied to clipboard
š BUG: Git is not found when using npm init astro on WSL2
What version of astro
are you using?
0.21.11
What package manager are you using?
npm
What operating system are you using?
Linux on WSL2 (Ubuntu 20.04.3 LTS)
Describe the Bug
$ npm init astro
npx: installed 16 in 4.911s
Welcome to Astro! (create-astro v0.6.9)
If you encounter a problem, visit https://github.com/withastro/astro/issues to search or file a new issue.
> Prepare for liftoff.
> Gathering mission details...
ā Directory not empty. Continue [force overwrite]? ā¦ yes
ā Which app template would you like to use? āŗ Starter Kit (Generic)
ā Which frameworks would you like to use? āŗ
> Copying project files...
could not find commit hash for latest
This seems to be an issue with degit. Please check if you have 'git' installed on your system, and install it if you don't have (https://git-scm.com).
If you do have 'git' installed, please file a new issue here: https://github.com/withastro/astro/issues
$ which git
/usr/bin/git
Might be related: I am on a machine without direct internet (npm packages come from a npmjs proxy)
Link to Minimal Reproducible Example
n/a
I have the same problem, but I'm using Windows instead
Terminal message
could not find commit hash for latest This seems to be an issue with degit. Please check if you have 'git' installed on your system, and install it if you don't have (https://git-scm.com). If you do have 'git' installed, please file a new issue here: https://github.com/withastro/astro/issues npm ERR! code 1 npm ERR! path C:\Users\ruben\Desktop\my-astro-site npm ERR! command failed npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c create-astro npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\ruben\AppData\Local\npm-cache_logs\2021-12-18T19_34_50_101Z-debug.log
Does anybody know how to fix it?
PS: I do have git install
I'm experiencing the exact same issue on Windows. I also have git installed.
Thanks for reporting, everyone. Iām unsure if this has been fixed since it was last reported, so Iām assigning this out to get tested and verified.
I know Windows Subsystem and Windows itself are different creatures, but from these reports 'Windows' does seem to be the common denominator.
Hello @hmvp @Raia17 and @warrengroom, do you all still have this issue? And if yes, could you please try to run the command with the --verbose
flag (https://github.com/withastro/astro/tree/main/packages/create-astro#debugging)?
Hey @Mikkel-T, I have just tried again and this is what I'm seeing:
PS C:\ASTRO\AST003> npm init astro my-astro-project -- --verbose
Need to install the following packages:
create-astro
Ok to proceed? (y) y
node:internal/errors:464
ErrorCaptureStackTrace(err);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'C:\Users\warre\AppData\Local\npm-cache_npx\57e9a3bcc0672894\node_modules\node-fetch' imported from C:\Users\warre\AppData\Local\npm-cache_npx\57e9a3bcc0672894\node_modules\create-astro\dist\index.js
at new NodeError (node:internal/errors:371:5)
at legacyMainResolve (node:internal/modules/esm/resolve:335:9)
at packageResolve (node:internal/modules/esm/resolve:877:14)
at moduleResolve (node:internal/modules/esm/resolve:929:18)
at defaultResolve (node:internal/modules/esm/resolve:1044:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
at ModuleWrap.
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\warre\AppData\Local\npm-cache_logs\2022-01-23T11_44_55_219Z-debug.log
Hey @warrengroom, can you please join the discord and open a support thread so that we can try to debug this? https://astro.build/chat
Trying astro first time today and got this issue. Any solutions please to overcome? I am using win10 command prompt with git already installed.
@Purus can you please try to run the command with the --verbose
flag (https://github.com/withastro/astro/tree/main/packages/create-astro#debugging) and send the output here?
Can anyone provide the Windows version they are running on when they run into this issue?
I reinstalled NPM/Astro after upgrading to Windows 11 and I'm no longer experiencing any issues. Sorry, I can't help debug.
Same issue with windows10 and git installed:
PS C:\Users\lenovo> npm create astro@latest --verbose
npm verb cli [
npm verb cli 'D:\\Node.js\\node.exe',
npm verb cli 'D:\\Node.js\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'create',
npm verb cli 'astro@latest',
npm verb cli '--verbose'
npm verb cli ]
npm info using [email protected]
npm info using [email protected]
npm timing npm:load:whichnode Completed in 0ms
npm timing config:load:defaults Completed in 1ms
npm timing config:load:file:D:\nvm\v16.15.0\node_modules\npm\npmrc Completed in 2ms
npm timing config:load:builtin Completed in 2ms
npm timing config:load:cli Completed in 1ms
npm timing config:load:env Completed in 1ms
npm timing config:load:project Completed in 3ms
npm timing config:load:file:C:\Users\lenovo\.npmrc Completed in 1ms
npm timing config:load:user Completed in 1ms
npm timing config:load:file:D:\nvm\node_global\etc\npmrc Completed in 0ms
npm timing config:load:global Completed in 0ms
npm timing config:load:validate Completed in 1ms
npm timing config:load:credentials Completed in 1ms
npm timing config:load:setEnvs Completed in 1ms
npm timing config:load Completed in 12ms
npm timing npm:load:configload Completed in 12ms
npm timing npm:load:setTitle Completed in 0ms
npm timing config:load:flatten Completed in 2ms
npm timing npm:load:display Completed in 9ms
npm verb logfile D:\nvm\node_cache\_logs\2022-07-14T01_54_38_248Z-debug-0.log
npm timing npm:load:logFile Completed in 5ms
npm timing npm:load:timers Completed in 0ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load Completed in 29ms
npm http fetch GET 200 https://registry.npmmirror.com/create-astro 184ms (cache revalidated)
npm timing arborist:ctor Completed in 1ms
npm timing arborist:ctor Completed in 0ms
npm timing arborist:ctor Completed in 0ms
Welcome to Astro! (create-astro v0.14.0)
Lets walk through setting up your new Astro project.
ā Where would you like to create your new project? ... astro-blog
ā Which template would you like to use? Ā» Just the basics (recommended)
ā ā ā¶ Copying project files...could not find commit hash for latest
This seems to be an issue with degit. Please check if you have 'git' installed on your system, and install it if you don't have (https://git-scm.com).
If you do have 'git' installed, please run this command with the --verbose flag and file a new issue with the command output here: https://github.com/withastro/astro/issues
ā ā ā ā¶ Copying project files...
npm timing command:create Completed in 15074ms
npm verb stack Error: command failed
npm verb stack at ChildProcess.<anonymous> (D:\nvm\v16.15.0\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27)
npm verb stack at ChildProcess.emit (node:events:527:28)
npm verb stack at maybeClose (node:internal/child_process:1092:16)
npm verb stack at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm verb cwd C:\Users\lenovo
npm verb Windows_NT 10.0.19044
npm verb argv "D:\\Node.js\\node.exe" "D:\\Node.js\\node_modules\\npm\\bin\\npm-cli.js" "create" "astro@latest" "--verbose"
npm verb node v16.15.0
npm verb npm v8.5.5
npm ERR! code 1
npm ERR! path C:\Users\lenovo
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c create-astro
npm verb exit 1
npm timing npm Completed in 15450ms
npm verb code 1
npm ERR! A complete log of this run can be found in:
npm ERR! D:\nvm\node_cache\_logs\2022-07-14T01_54_38_248Z-debug-0.log
Same issue here but on MacOS. Git is installed properly, exported in path, using it without no issues at all.
Running on Node 14.20 I get this:
01:44:20 AM [debug] Command failed: git ls-remote https://github.com/withastro/astro
fatal: not a git repository: /Users/martes/../.git/modules/secrets
ā ā ā ā¶ Copying project files...
01:44:20 AM [debug] DegitError: could not find commit hash for latest
at Degit._cloneWithTar (/Users/martes/.npm/_npx/29527/lib/node_modules/create-astro/node_modules/degit/dist/index-688c5d50.js:14258:10)
at async Degit.clone (/Users/martes/.npm/_npx/29527/lib/node_modules/create-astro/node_modules/degit/dist/index-688c5d50.js:14096:4)
at async main (file:///Users/martes/.npm/_npx/29527/lib/node_modules/create-astro/dist/index.js:115:7) {
code: 'MISSING_REF',
ref: 'latest'
}
could not find commit hash for latest
This seems to be an issue with degit. Please check if you have 'git' installed on your system, and install it if you don't have (https://git-scm.com).
If you do have 'git' installed, please run this command with the --verbose flag and file a new issue with the command output here: https://github.com/withastro/astro/issues
And Node 16:
npm timing command:create Completed in 15684ms
npm verb stack Error: command failed
npm verb stack at ChildProcess.<anonymous> (/Users/martes/.nvm/versions/node/v16.14.0/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
npm verb stack at ChildProcess.emit (node:events:520:28)
npm verb stack at maybeClose (node:internal/child_process:1092:16)
npm verb stack at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm verb cwd /Users/martes/Code
npm verb Darwin 21.4.0
npm verb argv "/Users/martes/.nvm/versions/node/v16.14.0/bin/node" "/Users/martes/.nvm/versions/node/v16.14.0/bin/npm" "create" "astro@latest" "--verbose"
npm verb node v16.14.0
npm verb npm v8.3.1
npm ERR! code 1
npm ERR! path /Users/martes/Code
npm ERR! command failed
npm ERR! command sh -c create-astro
npm verb exit 1
npm timing npm Completed in 15878ms
npm verb code 1
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/martes/.npm/_logs/2022-08-10T23_42_59_025Z-debug-0.log
I'm using create-astro v1.0.0
, and macOS 12.3
I had this same issue and realised it was in fact blocked by git
needing to authenticate with my SSH key i.e. there was a prompt in the background requesting a password. It seems the STDOUT was swallowed by the npm create
command.
It would stall at this point:
Same issue with --verbose

my environment:
- system macOS Monterey 12.5
- node v16.14.0
- create-astro v1.0.0
same issue
Windows10 21h2
Node.js v16.16.0
run npm create astro@latest
0 verbose cli C:\Program Files\nodejs\node.exe C:\Users\people\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Users\people\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 2ms
6 timing config:load:builtin Completed in 2ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:D:\Blogworkspace\asr\.npmrc Completed in 0ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:C:\Users\people\.npmrc Completed in 1ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:C:\Users\people\AppData\Roaming\npm\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 0ms
18 timing config:load Completed in 7ms
19 timing npm:load:configload Completed in 7ms
20 timing npm:load:mkdirpcache Completed in 1ms
21 timing npm:load:mkdirplogs Completed in 0ms
22 verbose title npm create astro@latest
23 verbose argv "create" "astro@latest" "--loglevel" "verbose"
24 timing npm:load:setTitle Completed in 1ms
25 timing config:load:flatten Completed in 1ms
26 timing npm:load:display Completed in 13ms
27 verbose logfile logs-max:10 dir:C:\Users\people\AppData\Local\npm-cache\_logs
28 verbose logfile C:\Users\people\AppData\Local\npm-cache\_logs\2022-08-16T05_01_04_657Z-debug-0.log
29 timing npm:load:logFile Completed in 15ms
30 timing npm:load:timers Completed in 0ms
31 timing npm:load:configScope Completed in 0ms
32 timing npm:load Completed in 40ms
33 silly logfile start cleaning logs, removing 2 files
34 timing arborist:ctor Completed in 1ms
35 silly logfile done cleaning log files
36 http fetch GET 200 https://registry.npmjs.org/create-astro 985ms (cache revalidated)
37 timing arborist:ctor Completed in 0ms
38 timing arborist:ctor Completed in 0ms
39 timing command:create Completed in 23883ms
40 verbose stack Error: command failed
40 verbose stack at ChildProcess.<anonymous> (C:\Users\people\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:63:27)
40 verbose stack at ChildProcess.emit (node:events:527:28)
40 verbose stack at maybeClose (node:internal/child_process:1092:16)
40 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
41 verbose cwd D:\Blogworkspace\asr
42 verbose Windows_NT 10.0.19044
43 verbose node v16.16.0
44 verbose npm v8.15.0
45 error code 1
46 error path D:\Blogworkspace\asr
47 error command failed
48 error command C:\WINDOWS\system32\cmd.exe /d /s /c C:\Users\people\AppData\Local\Temp\npx-c4a73d33.cmd
49 verbose exit 1
50 timing npm Completed in 24004ms
51 verbose code 1
52 error A complete log of this run can be found in:
52 error C:\Users\people\AppData\Local\npm-cache\_logs\2022-08-16T05_01_04_657Z-debug-0.log
@mattheworiordan I can confirm I'm using SSH auth for my git. Have you found a solution?
As I was researching this seems to be a general issue with NPM for those who uses SSH. There's an open issue here: https://github.com/npm/cli/issues/2610 which is still far from being resolved and it's a huge thread.
Some folks might be interested in these workarounds to get it working.
git config --global url."https://github.com/".insteadOf [email protected]:
git config --global url."https://".insteadOf git://
Also I've tried yarn
, npm
and pnpm
, all of them seems to have same problem so I believe it's core problem of node. Also both npm 6 and 7 are not working.