withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.81k stars 2.49k forks source link

🐛 BUG: sh: astro: command not found #2266

Closed datdoan closed 2 years ago

datdoan commented 2 years ago

What version of astro are you using?

0.22.1

What package manager are you using?

npm with nvm

What operating system are you using?

Mac with item

Describe the Bug

Using create-astro, getting error on npm run dev.

npm init astro

Welcome to Astro! (create-astro v0.7.0) 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... ✔ Which app template would you like to use? › Starter Kit (Generic) ✔ Which frameworks would you like to use? › Copying project files... ✔ Done!

Next steps: 1: npm install (or pnpm install, yarn, etc) 2: git init && git add -A && git commit -m "Initial commit" (optional step) 3: npm run dev (or pnpm, yarn, etc)

To close the dev server, hit Ctrl-C

Stuck? Visit us at https://astro.build/chat

⬢ v16.13.0 took 17s ➜ npm install npm WARN deprecated vscode-emmet-helper@2.1.2: This package has been renamed to @vscode/emmet-helper, please update to the new name

added 470 packages, and audited 471 packages in 53s

182 packages are looking for funding run npm fund for details

found 0 vulnerabilities

⬢ v16.13.0 took 53s ➜ npm run dev

@example/starter@0.0.1 dev astro dev

sh: astro: command not found

Link to Minimal Reproducible Example

none

matthewp commented 2 years ago

Very bizarre, not happening here with same Node version. Can you try running npm install again? Perhaps something didn't get installed.

datdoan commented 2 years ago

I have tried and still no luck. Also tried yarn create astro and return the same error: sh: astro: command not found

jonathantneal commented 2 years ago

@datdoan, are you able to try without nvm? Or can you check your nvm configuration? I’m wondering if this is an issue with your nvm configuration.

datdoan commented 2 years ago

I will give that a try and let you know, thanks.

datdoan commented 2 years ago

@datdoan, are you able to try without nvm? Or can you check your nvm configuration? I’m wondering if this is an issue with your nvm configuration.

without NVM it works, thank you for your help.

lesaff commented 2 years ago

Does this mean we can't use nvm with Astro?

cmoscosoz commented 2 years ago

I'm using NVM and I installed Astro globally (npm install -g astro) and then I've being using astro add, astro build etc.

glenharry commented 2 years ago

I ran npm install -g astro. Then after I could run npm run dev with no troubles.

camjmoore commented 1 year ago

I recently encountered the same problem and resolved it by globally installing as the solutions above mention. Does anybody have any insight as to why this still seems to require the same work around even though astro doesn't explicitly include any language about globally installing in their documentation?

kuworking commented 1 year ago

Very bizarre, not happening here with same Node version. Can you try running npm install again? Perhaps something didn't get installed.

Fixed for me.

It has happened just after installing npx astro add astro-compress

Then, npm run dev : sh: astro: command not found

Then npm install and it runs again

*("astro-compress": "2.0.15",)

ggrantrowberry commented 1 year ago

Very bizarre, not happening here with same Node version. Can you try running npm install again? Perhaps something didn't get installed.

Fixed for me.

It has happened just after installing npx astro add astro-compress

Then, npm run dev : sh: astro: command not found

Then npm install and it runs again

*("astro-compress": "2.0.15",)

I had this same thing happen to me when I ran npx astro add partytown. Running npm install fixed it.

samifouad commented 11 months ago

i wonder if there's some way to detect nvm and offer people a better dx? or perhaps document this behaviour? it seems that if you npm install on an existing project when nvm is managing node, and on this dev machine you have not yet initialized a new astro project, you must also run npm install -g astro in order to get things to work properly

i've been switching dev machines a lot this past year, so i've just become used to doing this, but i'm sure this is not a very obvious fix for people less familiar with the issue

Muzych commented 9 months ago

just run npm install or pnpm install

SkyeFull90 commented 8 months ago

I am currently seeing this inside of some projects when running npm, yarn or even bun dev. After a first installation, especially at night. below is some output i get when this happens.

dev astro dev

sh: 1: astro: not found

Process finished with exit code 127

Muzych commented 8 months ago

I am currently seeing this inside of some projects when running npm, yarn or even bun dev. After a first installation, especially at night. below is some output i get when this happens.

dev astro dev

sh: 1: astro: not found

Process finished with exit code 127

Have you try to running npm install again?

SkyeFull90 commented 8 months ago

I have done that multiple times with all package managers. Even deleting the whole directory and creating a new directory with the same name and get the same thing back astro not found.

PeterTolstrup commented 8 months ago

The problem can occur if you have "/" in a folder name or a parent's folder name. Changing that just resolved the problem for me. Also, it's probably not advisable to solve the problem by installing Astro globally. [edit, missing words/spelling]

SkyeFull90 commented 8 months ago

Thank you, I have switched to just using the cli tool when naming my frontend dir when using astro for it.

wrootz commented 4 days ago

The same!

sh: astro: command not found at npm run dev zsh: command not found: astro at astro dev

So, i tried starting npm install and npm fund and guess what?

npm run dev its working!