最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ng-serve command opens editor - Stack Overflow

programmeradmin3浏览0评论

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 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

Share Improve this question asked Dec 13, 2017 at 8:57 NDDTNDDT 5452 gold badges10 silver badges29 bronze badges 10
  • what happens if you just use ngas a command? maybe there's another software or alias that also listens to the ng command – Benedikt Schmidt Commented Dec 13, 2017 at 9:03
  • the same thing happens, the editor opens – NDDT Commented Dec 13, 2017 at 10:28
  • how can I remove this software and restore ng as the angular command? – NDDT Commented Dec 13, 2017 at 10:28
  • that's probably tricky, which OS are you on? usually there are commands to find out where the source of the software is something like which ng on Linux – Benedikt Schmidt Commented Dec 13, 2017 at 10:29
  • I'm on ubuntu, in a vagrant box. which ng shows "/usr/bin/ng" – NDDT Commented Dec 13, 2017 at 10:34
 |  Show 5 more comments

4 Answers 4

Reset to default 11

Solution :

Just use npx before any nodejs executables.

Eg : npx ng serve -o

I was able to resolve this by

  • unistalling the editor that took the ng-alias
  • uninstalling angular-cli
  • reinstalling angular-cli
  • manually adding the angular-cli alias

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. I run a Windows-11 OS.

I fixed the problem by going going to the environment variables menu, removing one of the values for the PATH variable. I removed the following lin, which pointed to my Angular JS:

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

  1. Remove the angular cli path from your environment variables
  2. Run npm config get prefix in your cmd or powershell
  3. Enter the path you get from step 2 into your path environment variable

Dont forget to restart your console

发布评论

评论列表(0)

  1. 暂无评论