简体   繁体   English

NG SERVE命令问题

[英]NG SERVE command issue

I got problem with running my angular app via ng serve. 我通过ng服务运行我的角度应用程序时出现问题。

After hours and hours of fighting with angular (had many problems with angular cli) I am able to generate project without errors. 经过几个小时的角度战斗(角度cli有很多问题)我能够毫无错误地生成项目。 I imported this project to IntelliJ and want to run by ng serve command. 我将此项目导入IntelliJ并希望通过ng serve命令运行。

after call ng serve got this: The program 'ng' is currently not installed. 在呼叫服务之后得到这个:当前没有安装程序'ng'。 You can install it by typing: sudo apt install ng-common 您可以通过键入以下命令安装它:sudo apt install ng-common

Any ideas? 有任何想法吗?

Make sure that you are running the "ng serve" command from inside the root directory of your angular project (the cli path is correct). 确保从角度项目的根目录内运行“ng serve”命令(cli路径正确)。

This error occurres because your command line interface cannot make sense of the command and whilst "ng new project" may execute from practically anywhere, other ng commands such as "ng serve" can only execute from within the project root directory. 发生此错误的原因是您的命令行界面无法理解命令,而“ng new project”可能几乎从任何地方执行,其他ng命令(如“ng serve”)只能从项目根目录中执行。

Hope this guide will help you to create a project without errors. 希望本指南能帮助您创建一个没有错误的项目。

1. first open terminal or console window and run, npm install -g @angular/cli
2. To create a new workspace and initial starter app, ng new my-app-name
3. Go to my-app-name folder, cd my-app-name
4. Launch the server by using the CLI command, ng serve --o (--o to open in browser)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM