when you run ng new app-name it will create a new directory with app name and install everything in that.
after running the above command, human tendency is to run ng serve
and because your app is in sub directory it will not find package.json and throw the mentioned error.
Solution is pretty simple. just move to the sub directory and then run ng serve
In your example you are missing new. This would create folder, generate files and run npm install for you.
It seems that you've created folder but there's no Angular CLI app in it.
And for starting the app use:
ng serve
npm start is only used if you have ejected from cli.
Below steps worked for me:
Delete node_modules folder and package-lock.json file. npm install ng serve
i got the same issue, and the reason is
ng new app-name
it will create a new directory with app name and install everything in that.ng serve
and because your app is in sub directory it will not find package.json and throw the mentioned error.Solution is pretty simple. just move to the sub directory and then run
ng serve
You create new project with:
In your example you are missing
new
. This would create folder, generate files and runnpm install
for you. It seems that you've created folder but there's no Angular CLI app in it.And for starting the app use:
npm start
is only used if you have ejected from cli.Try to run
in the project folder
May help you.
This will solve you problem.
**You should be in the newly created YOUR_APP folder before you hit the ng serve command **
Lets start from fresh,
1)
install npm
2) create a new angular app (
ng new <YOUR_APP_NAME>
)3) go to app folder (
cd YOUR_APP_NAME
)4)
ng serve
I hope it will resolve the issue.