programing

Angular CLI 오류 : serve 명령을 Angular 프로젝트에서 실행해야하지만 프로젝트 정의를 찾을 수 없습니다.

nasanasas 2020. 8. 14. 07:51
반응형

Angular CLI 오류 : serve 명령을 Angular 프로젝트에서 실행해야하지만 프로젝트 정의를 찾을 수 없습니다.


터미널 명령 ng server또는을 실행할 ng serve --live-reload=true때이 문제가 발생합니다.

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


나는 또한이 문제를 얻고 있었고 아래 명령을 실행하여 해결했습니다.

ng update @angular/cli --migrate-only --from=<WhateverVersionYouAreCurrentlyOn>

예 :

ng update @angular/cli --migrate-only --from=1.7.3

여기에서 심판 받기 https://github.com/angular/angular-cli/issues/12215#issuecomment-433593036


응용 프로그램 루트 폴더에서 명령을 실행하고 있는지 확인하십시오.


프로젝트를 다운로드 한 경우 프로젝트에서 수행하십시오.

npm 설치


마지막으로 아래 명령이 문제를 해결했습니다!

업데이트 --all --force


Angular Cli 오류 : serve 명령을 Angular 프로젝트에서 실행해야하지만 프로젝트 정의를 찾을 수 없습니다.

angular.json 파일이 누락되었습니다.

    ng update --all --force

Angular 7+에서 테스트


프로젝트에서 새 각도 버전 구성을 설정했는지 확인하십시오. 새로운 angular cli는 구성에 .angular-cli.json이 아닌 angular.json을 사용합니다.

마이그레이션 가이드를 따르십시오 .


패키지 관리자 콘솔에서 다음 명령을 실행하십시오.

PM> cd NameofApp 

그런 다음 거기에서 명령을 실행할 수 있습니다.

PM > ng generate component Home

Angular 응용 프로그램의 루트 폴더 대신 다른 폴더에서 Angular 명령 "ng s"또는 "ng serve"를 실행하려고 할 때 발생합니다.

또한 다음 명령을 사용하여 Angular를 업그레이드하십시오.

ng update @angular/cli --migrate-only --from=1.7.4

이것은 그것을 분류합니다.


응용 프로그램을 실행하기 전에 루트 폴더로 이동해야하기 때문에 Angular7에서 동일한 문제가 발생했습니다. 앱의 루트 폴더로 이동하여 명령을 실행하십시오. 그것은 나를 위해 완벽하게 작동합니다.


내가 만난 것과 같은 문제이지만 다음 단계의 코드를 따라 해결했습니다.

Step 1) npm install -g @angular/cli
Step 2) ng new my-angular-project
Step 3) cd my-angular-project
Step 4) ng serve --open

최신 nodenpm패키지 로 업데이트하려고 할 때 기존 프로젝트에서 발생했습니다 .

  1. 전역 제거 : npm uninstall -g angular-cli
  2. 캐시 재설정 : npm cache clean또는 npm cache verify( npm version> 5)
  3. 최신 설치 : npm install -g @angular/cli@latest

같은 오류가 발생했습니다. 그 이유는 새로운 angular cli 업데이트로 인해 angular-cli.json이 중복되고 대신 angular.json으로 대체되기 때문입니다. 이전 Angular Cli 버전은 1.7.4이므로 변경하기 위해 다음 명령을 실행하면 변환이 수행됩니다.

ng update @angular/cli --migrate-only --from=1.7.4

나는 같은 문제에 직면했을 때

이전 angular-cli 버전 (1.4.7)을 사용하여 새로운 각도 프로젝트를 만들었습니다. 그런 다음 아래 명령을 사용하여 angular-cli를 업데이트했습니다 (CLI를 업데이트하려면 아래를 수행하지 마십시오 )

  • npm uninstall -g @angular/cli
  • npm cache clean --force
  • npm install -g @angular/cli@latest

이제 시도했을 때 너와 ng serve같은 오류가 발생했습니다.

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

아래에서 CLI를 업데이트하십시오.

ng update @angular/cli --migrate-only --from=1.4.7

Usman이 말했듯이 처음에는 많은 문제가 있었고 튜토리얼을 따르고있었습니다. 내 디렉토리를 프로젝트 디렉토리로 설정하지 않았 으므로이 오류가 발생했습니다.

나는 문제를 해결했다.

  1. 내 프로젝트가 있던 위치에 올바른 루트 디렉토리 설정 cd myproject
  2. 앱 컴파일- ng serve

그거였다.


이 오류는 실행중인 프로젝트가 각도 프로젝트가 아닐 때 발생합니다. 각도 프로젝트를 다운로드했지만 모든 종속성을 설치하지 않았기 때문에 ng serve 명령을 사용할 수 없습니다.

프로젝트가 저장된 경로로 이동하고 명령을 사용하십시오.

npm install

(Note - Node.js should be installed in your system and if you are using Angular 2 or above angular cli should also be installed in your system before you run this command. To check if the node.js is installed n your system 1) Open cmd (any path- as node should be globally installed in your system) 2) use command

node -v
npm -v

to get node and npm version)

One more important thing: The angular cli version won't make a difference if the version installed in your system is higher than the version required by the project. It will give a warning but you can ignore the warning.


This error may be occur when we are in wrong directory.so use cd command to change your directory. It's not very evident from the above comment that which specific command is giving this error so this answer is based on assumption that you are running ng serve outside the root folder/actual project folder. That's why it's giving error because cli commands require conf & build files to run the cli build.

These should be the steps:
npm install -g @angular/cli  //corrected from 'angular-cli'
ng new projectname
cd projectname
ng serve
open http://localhost:4200

Also make sure if you are running ng serve that you stop it first...


Solved. I was getting same issue on ubuntu 18.04.01 LTS. No above options worked as I was using NVM (Node Version manager.) Solution is
before creating project,use command
nvm use 10
(my node version was 10.15.0, so I used "nvm use 10")
It will show you output-
Now using node v10.15.0 (npm v6.4.1)
Versions will vary as per individual systems. then create new project.


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


Please check whether you are inside your project folder or not and try the command ng serve again

I got the same error since I tried ng serve command outside of my project

Example :: let's say you have a project with name "Ecommerce" traverse into the folder and try the command ng serve open terminal cd Ecommerce ng serve


In my case, I forgot to change my directory, so just after running the command :

ng new AngularProject

execute another command :

cd AngularProject

and ng serve worked for me.


This fixed my problem:

ng generate component nameComponent --module app.module

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


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

ng new Project_Name


Tried all the above But for me it was solved by

npm start

참고URL : https://stackoverflow.com/questions/53096996/angular-cli-error-the-serve-command-requires-to-be-run-in-an-angular-project-b

반응형