Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You have to be inside an angular-cli project in order to use the serve command

Tags:

angular

I am trying to run a drag and drop sample from dragula.but when i run ng serve it complains with :

You have to be inside an angular-cli project in order to use the serve command.

when i run ng -v in my machine, I have:

angular-cli: 1.0.0-beta.16
node: 4.6.0
os: win32 x64

I have tried to add:

"angular-cli": "1.0.0-beta.16",

in the dependencies of project and then npm install, but my node fails to install the package.

How can i run the dragula?

like image 868
Sal-laS Avatar asked Nov 30 '16 11:11

Sal-laS


People also ask

How do you fix the serve command requires to be run in an Angular project but a project definition could not be found?

This error often occurs when a project you are running is not an Angular project. It may also be the case when you download an Angular project but do not have latest dependencies installed on your machine. Installing latest dependencies should fix the problem.

Which command is used to serve the Angular app?

ng serve command builds and serve the application. It rebuilds the application if changes occur. Here project is the name of the application as defined in angular. json.

Can I use NG serve in production?

ng serve is a great command to use when developing your application locally. It starts up a local development server, which will serve your application while you are developing it. It is not meant to be used for a production environment.


3 Answers

If I understand you correctly, you want to run the dragula demo.

Apparently dragula was not created using an angular cli project. So running the ng serve command from the demo folder will not yield any results.

Instead you should run the application using node.

First update your angular CLI to make sure it is the most recent version.

npm install -g @angular/cli@latest

or

yarn global add @angular/cli@latest

Next install all dependencies by executing npm install or npm i from the directory you downloaded the package to. This downloads and installs all the dependencies mentioned in the package.json file and their dependencies.

Then you can run the development build by using the npm start command. This will transpile the typescript and creates a webpack that can be accessed using the url given in the console (http://localhost:4200 by default). You could also try to use the ng serve command again.

like image 189
kacase Avatar answered Dec 23 '22 06:12

kacase


if ng serve doesn't work try npm start.

I don't know the exact reason, but for me it works !!

like image 22
hannes neukermans Avatar answered Dec 23 '22 06:12

hannes neukermans


Try installing npm install -g @angular/cli@latest since the angular-cli has been renamed.

like image 20
Rahul Kumar Avatar answered Dec 23 '22 05:12

Rahul Kumar