Angular CLI Error: The serve command requires to b

2020-01-24 10:48发布

When running the terminal commands ng server or ng serve --live-reload=true, I'm getting this issue:

The serve command requires to be run in an Angular project, but a project definition could not be found.

30条回答
我命由我不由天
2楼-- · 2020-01-24 11:28

It was silly me but need to leave comment maybe I save someone else some hassle. Same message happens if you multitask and have multiple projects so some of project is nested inside project folder like projectFolder/subProject/projectOne so I was in projectFolder/subProject trying to run command ng serve.

Make sure you are in correct folder because same error will occur if you are in wrong folder and conf and build is missing!

查看更多
贪生不怕死
3楼-- · 2020-01-24 11:28

You can update the angular with command 'ng update --all'. It will take time but make sure your all components are up to date.

查看更多
forever°为你锁心
4楼-- · 2020-01-24 11:28

Make sure you have created angular App using below command, then running ng serve in created Project folder.

ng new Project_Name

查看更多
冷血范
5楼-- · 2020-01-24 11:29

This happens because we are hitting ng serve command in some other path.This can be solved by hitting ng serve or npm start command on the path where exactly the our project resides(take path until the folder which contains src,node_modules,etc.)

F:\project\AngularDemo\AngularDemoapp> ng serve

查看更多
女痞
6楼-- · 2020-01-24 11:30

make sure that you are running the command in the application root folder..

查看更多
我欲成王,谁敢阻挡
7楼-- · 2020-01-24 11:30

In your Package Manager Console run the command

PM> cd NameofApp 

then you can try to run the command there.For instance

PM > ng generate component Home
查看更多
登录 后发表回答