Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 生成角度代码时出错_Angular - Fatal编程技术网

Angular 生成角度代码时出错

Angular 生成角度代码时出错,angular,Angular,我创建了angular应用程序,但在执行命令“ng serve”时出错 错误是:build命令需要在角度项目中运行,但找不到项目定义 我曾尝试安装@angular/cli、devkit core和angular软件包,但仍然面临相同的错误 我不知道我错过了什么。我在谷歌搜索了很多,但无法解决这个错误 已编辑:已添加图像。 在终端中(命令可能因终端而异): 如果此时出现该错误,请查找当前Angular CLI版本并进行更新: [my-test] ng -v [my-test] _

我创建了angular应用程序,但在执行命令“ng serve”时出错

错误是:build命令需要在角度项目中运行,但找不到项目定义

我曾尝试安装@angular/cli、devkit core和angular软件包,但仍然面临相同的错误

我不知道我错过了什么。我在谷歌搜索了很多,但无法解决这个错误

已编辑:已添加图像。

在终端中(命令可能因终端而异):

如果此时出现该错误,请查找当前Angular CLI版本并进行更新:

[my-test] ng -v
[my-test] 
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.7.4
Node: 8.9.3
OS: darwin x64
Angular: 5.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.7.4
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0

[my-test] ng update @angular/cli --migrate-only --from=<1.7.4>
[my test]ng-v
[我的测试]
_                      _                 ____ _     ___
/ \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
/ ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
|___/
角度CLI:1.7.4
节点:8.9.3
OS:Darwinx64
角度:5.2.11
…动画、通用、编译器、编译器cli、核心、窗体
…http、语言服务、平台浏览器
…平台浏览器、动态路由器
@角度/cli:1.7.4
@角度开发工具包/构建优化器:0.3.2
@角度devkit/核心:0.3.2
@角度devkit/示意图:0.3.2
@ngtools/json模式:1.2.0
@ngtools/网页包:1.10.2
@示意图/角度:0.3.2
@示意图/组件更新:0.3.2
打字稿:2.5.3
网页:3.11.0
[我的测试]ng update@angular/cli--仅迁移--来自=
这样,您将更新Angular CLI。请注意您自己的版本。如您所见,在我的示例中,它是1.7.4,但您的版本可能会有所不同


基于

请确保您正在项目目录中运行
ng serve
,我正在cli中编写正确的命令,并且我已编辑了我的问题。您可以发布命令提示符的快照吗?@AmiVyas通过“ng new myapp”创建新项目后,您需要通过“cd myapp”进入“myapp”目录,然后运行“ng serve”共享屏幕截图在命令提示符下,尝试创建一个新的空项目并为其提供服务
[my-test] ng -v
[my-test] 
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.7.4
Node: 8.9.3
OS: darwin x64
Angular: 5.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.7.4
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0

[my-test] ng update @angular/cli --migrate-only --from=<1.7.4>