bash/usr/bin/ng:Angular中没有这样的文件或目录 [英] bash /usr/bin/ng: No such file or directory in Angular

查看:223
本文介绍了bash/usr/bin/ng:Angular中没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我通过ng serve运行Angular项目时,会出现此错误:

When I run my Angular project by ng serve, it gives this error:

bash:/usr/bin/ng:没有这样的文件或目录

bash: /usr/bin/ng: No such file or directory

我已经运行了npm install -g @angular/cli

推荐答案

我遇到了同样的问题,这对我有用.

I faced the same problem and here is what worked for me.

1)通过运行-

ls -la ~/ | more

2)在编辑器中打开,在我的情况下为emacs-

2) Open in editor, in my case emacs -

emacs ~/.bashrc

3)在文件末尾添加一个别名,指向ng目录的正确路径&保存文件.例如-

3) Add an alias at the end of the file pointing to the right path of your ng directory & save the file. e.g. -

alias ng="/usr/local/lib/node_modules/@angular/cli/bin/ng"

4)重新启动终端或使用-

4) Either restart the terminal or refresh it using -

sudo source ~/.bashrc

5)现在通过运行ng -v

这篇关于bash/usr/bin/ng:Angular中没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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