0

我正在使用角度控制台来运行和测试等我的应用程序。这工作正常。但是当我尝试通过终端运行它而不使用角度控制台时,它会抛出以下内容 -bash: ng: command not found

我确保node_module通过npm install在特定项目下安装,使用/安装所有依赖项。

此外,当我尝试运行时ng -v,我收到相同的消息-bash: ng: command not found:我假设@angular/cli在我的机器或类似的东西上全局安装不正确。

我一直在 SO 中搜索,发现了类似的问题,但我认为我的问题似乎有所不同。此外,我不是 100% 确定它是否与角度控制台有关,但我只是问自己为什么它在使用时有效,angular console但在直接使用终端时无效?

任何提示如何解决/解决这个问题?

4

1 回答 1

0

问题已根据以下问题的答案解决

解决方案:

# create a new directory where npm will install packages
$  mkdir ~/.node_modules

# set npm "prefix" config to that directory
$  npm config set prefix '~/.node_modules'

# append a line to your .zshrc instructing it to include that directory in your $PATH, making the executables known to the shell
$ echo 'export PATH=~/.node_modules/bin:$PATH' >> ~/.zshrc

# update current shell with new path (not needed for new sessions)
$ source ~/.zshrc
于 2019-07-03T11:07:30.347 回答