【发布时间】:2019-12-11 20:00:06
【问题描述】:
更新到最新版本的 Angular CLI 后,我无法再执行 ng serve 命令。但是使用yarn start 或npm start 确实允许像往常一样运行ng serve 命令。
尝试为 Angular 安装最新的 CLI 版本,但没有任何帮助。 以下是命令提示符快照以供参考。
Microsoft Windows [Version 10.0.17134.885] (c) 2018 Microsoft
Corporation. All rights reserved.
D:\Development\Celebro>ng serve 'ng' is not recognized as an internal
or external command, operable program or batch file.
D:\Development\Celebro>ng 'ng' is not recognized as an internal or
external command, operable program or batch file.
D:\Development\Celebro>yarn start
> yarn run v1.17.3
> $ ng serve
> 15% building 3/3 modules 0 activeTerminate batch job (Y/N)? y
D:\Development\Celebro>npm start
> Celebro@0.0.0 start D:\Development\Celebro
> ng serve
> 10% building 3/3 modules 0 activeTerminate batch job (Y/N)? y
D:\Development\Celebro>
我已经安装了最新的 CLI/Node/检查了 Windows 环境路径变量,到目前为止没有任何帮助。
【问题讨论】:
-
你全局安装了angular cli吗?
-
是的,它是全局安装的,但奇怪的是我什至无法运行 ng version 命令。
-
它与您的项目一起安装,而不是全局安装。这就是为什么它可以使用 npm run 而不是 ng 运行的原因
-
Windows... 您缺少全局安装。请记住,安装后,您必须重新启动终端窗口才能使其正常工作。如果之后还是不行,你可能需要检查并配置环境变量
标签: angular angular-cli