ng serve命令无法正常工作,角度为5 [英] ng serve command not working angular 5

查看:442
本文介绍了ng serve命令无法正常工作,角度为5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我运行ng serve,则会收到此错误

If I run ng serve, getting this error

ng:术语"ng"未被识别为cmdlet,函数,脚本文件或可运行程序的名称.检查名称的拼写,或者 如果包含路径,请确认路径正确,然后重试. 在第1行:char:1 + ng服务 + ~~ + CategoryInfo:ObjectNotFound:(ng:String)[],CommandNotFoundException + FullyQualifiedErrorId:CommandNotFoundException

ng : The term 'ng' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + ng serve + ~~ + CategoryInfo : ObjectNotFound: (ng:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

我已经尝试过npm run ng serve,但收到此错误

I have tried npm run ng serve, getting this error

找不到本地工作区文件('angular.json'). 错误:找不到本地工作空间文件('angular.json'). 在WorkspaceLoader._getProjectWorkspaceFilePath(C:\ Users \ rohit \ AppData \ Roaming \ npm \ node_modules \ @angular \ cli \ models \ workspace-loader.js:3 7:19) 在WorkspaceLoader.loadWorkspace(C:\ Users \ rohit \ AppData \ Roaming \ npm \ node_modules \ @angular \ cli \ models \ workspace-loader.js:24:21) 在ServeCommand._loadWorkspaceAndArchitect(C:\ Users \ rohit \ AppData \ Roaming \ npm \ node_modules \ @angular \ cli \ models \ architect-command.js:180:3 2) 在ServeCommand. (C:\ Users \ rohit \ AppData \ Roaming \ npm \ node_modules \ @angular \ cli \ models \ architect-command.js:47:25) 在Generator.next() 在C:\ Users \ rohit \ AppData \ Roaming \ npm \ node_modules \ @angular \ cli \ models \ architect-command.js:7:71 在新的Promise() 在__awaiter(C:\ Users \ rohit \ AppData \ Roaming \ npm \ node_modules \ @angular \ cli \ models \ architect-command.js:3:12) 在ServeCommand.initialize(C:\ Users \ rohit \ AppData \ Roaming \ npm \ node_modules \ @angular \ cli \ models \ architect-command.js:46:16) 在对象. (C:\ Users \ rohit \ AppData \ Roaming \ npm \ node_modules \ @angular \ cli \ models \ command-runner.js:87:23) npm ERR!代码ELIFECYCLE npm ERR! errno 1 npm ERR! npv2@0.0.0 ng:ng "serve" npm ERR!退出状态1 npm ERR! npm ERR!在npv2@0.0.0 ng脚本处失败. npm ERR! npm可能不是问题.上面可能还有其他日志记录输出.

Local workspace file ('angular.json') could not be found. Error: Local workspace file ('angular.json') could not be found. at WorkspaceLoader._getProjectWorkspaceFilePath (C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\workspace-loader.js:3 7:19) at WorkspaceLoader.loadWorkspace (C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\workspace-loader.js:24:21) at ServeCommand._loadWorkspaceAndArchitect (C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:180:3 2) at ServeCommand. (C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:47:25) at Generator.next () at C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:7:71 at new Promise () at __awaiter (C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:3:12) at ServeCommand.initialize (C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:46:16) at Object. (C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\command-runner.js:87:23) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! npv2@0.0.0 ng: ng "serve" npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the npv2@0.0.0 ng script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\rohit\AppData\Roaming\npm-cache\_logs\2018-06-12T06_59_12_392Z-debug.log

我已卸载@ angular/cli并清除了缓存,再次安装但遇到相同的问题.

I have uninstall @angular/cli and cleared the cached, again installed but facing same issue.

请提出建议.

推荐答案

这可能是由于angular-cli版本不同所致. 检查angular-cli的版本,您不应拥有版本6,而应使用1.7. 原因是在angular 6中,配置位于angular.json文件中.在1.7版中,配置位于angular-cli.json

This could be due to different versions of angular-cli. Check the version of angular-cli, you should not have version 6, but use 1.7. Cause in angular 6 the configuration is in angular.json file. In version 1.7 the configuration is in angular-cli.json

这篇关于ng serve命令无法正常工作,角度为5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆