Astro npm run dev does not work
Hi everyone,
As the main subject says, when i first start a new Astro project, with the following installation options steps:
1- npm create astro@latest
2- Choose a directory name "example"
3- How would you like to start your new project: empty
4- Do you plan to write Typescript: No
5- Install dependencies?: Yes
6- Initialize a new Git repo: No
Once everything installed:
7- cd into "example"
8- run "npm run dev"
And i've got the uploaded image error message.
I've found out a fix, if i run "npm install typescript" or "npm install --dev typescript@latest " in the folder project, and then run "npm run dev" it WORKS !!!.
It works if i choose in the installation process that i want to use typescript too.
But i shouldn't do this, because it should work out of the box, without manually installing typescript modules.
So here i am, i don't really understand why i can't run the project without typescript normally, as it should.
Hope i was clear enough.
Thank you for your time and read this !!!
26 Replies
between 7 and 8, you need to run
npm install
did it, but it didnΒ΄t work, here you have a screenshot
thanks for the quick reply btw, and live long and prosper of course
That's an odd bug then... Especially cause you're selecting no typescript
indeed, it doesn't make any sense, because i've watched @Kevin doing it without typescript and worked like a charm
I have used Astro many times and never had this problem. I see that you did omit the npm install initially and you also tinkered a bit by installing Typescript. My guess is you did some other changes you did not mention and maybe even forgot, and those changes introduced new problems. I recommend starting again from the beginning and just remember to npm install. My guess is that was the original problem and you created some new problems while trying to fix that.
hi there, thanks for the reply. My guess was the same as you mentioned, something i did that i didn't notice before, so i did a few more new fresh projects, without doing anything else that the steps i've mentioned before. I have deleted the node_modules and reinstalled with npm install even, but no success. Only works when i manually install typescript or choose a typescript project.
Did you start a completely new project or did you try to reset by deleting node_modules? I recommend a completely new project. You should not need to delete or reinstall anything for this to work.
yep, completly new project. I'm using NVM with 22.8.0 node version
I just tested creating a new project with your options and it worked without any problems.
thank you for the time your taking to help me, here you go my screen, i did it a few seconds ago
Interesting. I do have Typescript installed globally. Maybe there is a bug in Astro that I did not notice because Typescript is available. I recommend trying to do
You might need to start a new project from scratch again after that.
already done a few seconds ago, the same result
iΒ΄m starting to think there might be something to do with nvm or node versions
NVM: 1.1.11
Node: 22.8.0
NPM: 10.8.2
I noticed that the error mentions Zod. Did you install that separately or modified the starter code with Zod as a dependency?
not at all, and the craziest things it is already there
Was example-three a completely empty folder or non-existent prior to creating the Astro project?
yep, completly new folder created in the installation process
This is very unusual and I don't know why it is happening.
yeah, the same happens to me, i'm totally lost. I have even used a different internet connection, in the case some dependencies didn't install properly and no luck
donΒ΄t worry, i'm already working with the "npm install typescript" solution, i'll have to settle
The other strange thing is a local install of Typescript works but the global one didn't. Is there some kind of extra security on your computer? Are you using an account with restricted permissions? For example, is this a school owned computer?
it's my own personal computer, but i'm working on a restricted work internet connection at my job, that is why i've tryed with my mobile data connection. I've even given full access folder permissions in my windows config in order to let it delete, write or modify whatever it needs
are you sure you only need to run
npm install
and not npm install --save-dev
?
typescript is a development dependencyi've just installed with npm install and npm install --save-dev, same result, same error
are you guys using NVM ?
im not using anything in my pc
it's just something i noticed
thank you