简体   繁体   English

zsh:找不到命令:ng

[英]zsh: command not found: ng

I have setup my angular project in bash terminal(default one).我已经在 bash 终端(默认终端)中设置了我的 angular 项目。 Command like命令像

ng s

It worked fine.它运作良好。

Now I change my default terminal to zsh.现在我将我的默认终端更改为 zsh。 On running command在运行命令

ng serve 

throws error:抛出错误:

zsh: command not found: ng

It work fine if I switch my new default-terminal(zsh) to bash;如果我将新的默认终端(zsh)切换到 bash,它就可以正常工作; again to zsh.再次使用 zsh。 I think zsh does not understand the packages installed in bash initially我认为 zsh 最初不理解 bash 安装的包

How to fix this command not found issue?如何修复此命令未找到的问题?

Possibly, on startup bash adds ng location to PATH, but zsh doesn't.可能在启动时 bash 将 ng 位置添加到 PATH,但 zsh 没有。 You can check ~/.bashrc and ~/.bashprofile to see what is added to the PATH variable (all lines starting with export...), and copy these lines to ~/.zshrc file.您可以检查 ~/.bashrc 和 ~/.bashprofile 以查看添加到 PATH 变量中的内容(所有以 export... 开头的行),并将这些行复制到 ~/.zshrc 文件。

To solve the error "ng: command not found", install the angular cli package globally by npm install -g @angular/cli@latest and restart your terminal.要解决错误“ng: command not found”,请通过npm install -g @angular/cli@latest全局安装 angular cli package 并重新启动终端。

If the global installation of Angular fails, you might have to run the command prefixed with sudo .如果 Angular 的全局安装失败,您可能必须运行以sudo为前缀的命令。

get package version ng version .得到 package 版本ng version

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

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