Angular:不能使用 ng-Command

NDD*_*DDT 2 node.js npm angular-cli angular

我正在尝试在 vagrant-box 中安装 angular。

npm install -g @angular/cli
Run Code Online (Sandbox Code Playgroud)

遗憾的是,当我尝试使用客户端时出现此错误:

The program 'ng' is currently not installed. You can install it by typing:
sudo apt install ng-common
Run Code Online (Sandbox Code Playgroud)

(ng-common 似乎是一个文本编辑器?)

有谁知道我怎样才能让它运行?

我尝试卸载并重新安装。

编辑:我在 vagrant-box 中运行 Ubuntu,我只在里面工作。即使我跳过了两个可选的依赖项,安装也已完成。

NDD*_*DDT 8

我发现了这个问题:

我安装了两个不同版本的 angular-cli:

npm install -g @angular/cli
npm install -g angular-cli
Run Code Online (Sandbox Code Playgroud)

第二行安装了一个旧版本,这会产生冲突。您可以使用此行检查安装了哪些版本:

npm list -g --depth=0
Run Code Online (Sandbox Code Playgroud)

我无法“ npm uninstall ”它,所以我用“ sudo rm ”从节点文件夹中删除了它。

最后我添加了路径(无论你的节点在哪里,这都可以工作):

echo -e "export PATH=$(npm prefix -g)/bin:$PATH" >> ~/.bashrc && source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)