简体   繁体   English

ng-serve 命令打开编辑器

[英]ng-serve command opens editor

I set up a fresh angular-app and try to serve it with我设置了一个新的角度应用程序并尝试使用

ng serve --watch

instead of serving the app a file-editor opens.文件编辑器打开而不是为应用程序提供服务。 Why does that happen?为什么会这样? How can I resolve this?我该如何解决这个问题?

this is the editor that shows这是显示的编辑器

Serving with服务与

npm start

works fine工作良好

I was able to resolve this by我能够解决这个问题

  • unistalling the editor that took the ng-alias卸载使用 ng-alias 的编辑器
  • uninstalling angular-cli卸载 angular-cli
  • reinstalling angular-cli重新安装 angular-cli
  • manually adding the angular-cli alias手动添加 angular-cli 别名

Solution :解决方案:

Just use npx before any nodejs executables.只需在任何 nodejs 可执行文件之前使用 npx。

Eg : npx ng serve -o例如: npx ng serve -o

I don't know how I got there, but suddenly ng serve behaved differently and opened the ng.js file, in the default editor app actually called Editor .我不知道我是怎么到那里的,但突然ng serve的行为有所不同并打开了ng.js文件,在默认的编辑器应用程序中实际上称为Editor I run a Windows-11 OS.我运行 Windows-11 操作系统。

I fixed the problem by going going to the environment variables menu, removing one of the values for the PATH variable.我通过转到环境变量菜单,删除 PATH 变量的一个值来解决这个问题。 I removed the following lin, which pointed to my Angular JS:我删除了以下 lin,它指向我的 Angular JS:

C:\path\to\node_modules\@angular\cli\bin

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

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