【问题标题】:Angular cli - ng command open the ng fileAngular cli - ng 命令打开 ng 文件
【发布时间】:2018-12-01 20:47:46
【问题描述】:

我有一个 Angular 项目,如果我想用 'ng serve' 启动项目,它会打开 ng 文件

C:\Users{user}\AppData\Roaming\npm\node_modules\@angular\cli\bin

另外,我可以使用“npm start”启动项目。

【问题讨论】:

  • 您使用的是哪个版本?用于 Angular 2+ ng new YourProjectName 创建项目和 ng serve 运行。
  • 如果您能够运行其他命令,例如 ng new app,ng serve -o 应该也可以,您使用的是什么版本的 angular cli?
  • 对 ng 的任何命令都不起作用。该项目来自 github,我只能使用 npm start 运行。
  • 你可能缺少 npm cli
  • 'npm' 工作。 'ng' 只是从该路径打开 ng 文件。它不执行任何操作

标签: angular angular-cli


【解决方案1】:

问题是我在 powershell 中使用了 ng。在cmd中工作..

【讨论】:

  • o...m...g.这对我来说花了1个小时。感谢您的评论。为什么它不能在 powershell 中工作?
  • 这里有类似的问题...我无法让它在 Visual Studio Code 中工作,但它在 gitbash 终端中工作正常
  • 也适合我。在我的情况下,这是正确的解决方案。
【解决方案2】:

从环境变量 - 路径中删除路径“C:\Users{user}\AppData\Roaming\npm\node_modules@angular\cli\bin”。它对我有用。

【讨论】:

  • 当路径被移除时 NG 无法识别,当路径被添加时,它会尝试在 angular-cli 二进制路径中打开 NG.JS 文件
猜你喜欢
  • 1970-01-01
  • 2021-12-21
  • 2017-12-31
  • 1970-01-01
  • 1970-01-01
  • 2019-03-25
  • 2021-09-28
  • 2013-04-11
  • 2020-01-27
相关资源
最近更新 更多