ng:找不到命令 [英] ng: command not found

查看:49
本文介绍了ng:找不到命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的项目文件夹中运行 ng build,但我得到以下响应:

I am trying to run ng build in my project folder, but I get the following response:

bash: ng: 找不到命令

bash: ng: command not found

我错过了什么?它是否与管理员权限、我的路径/配置文件或我需要全局安装的东西有关?

What am I missing? Does it have to do with admin privileges, my path/profile, or something I need to install globally?

这是我的package.json:

This is my package.json:

{
"name": "meanauthapp",
"version": "1.0.0",
"description": "MEAN stack authentication app",
"main": "app.js",
"scripts": {
"start": "node app"
},
"dependencies": {
"express": "4.16.2",
"mongoose": "4.13.6",
"bcryptjs": "2.4.3",
"cors": "2.8.4",
"jsonwebtoken": "8.1.0",
"body-parser": "1.18.2",
"passport": "0.4.0",
"passport-jwt": "3.0.1"
},
"author": "",
"license": "MIT",
"devDependencies": {
  "@angular/cli": "^1.6.0"
  }
}

推荐答案

如果其他人像我一样遇到这个问题,这里是我在 MacOS 系统范围内解决它的方法.希望这会有所帮助.

In case others come here with this issue as I have, here is how I solved it system-wide on MacOS. Hope this helps.

验证节点是否已安装:

$ node -v
v11.2.0

验证 npm 是否已安装:

Verify npm is installed:

$ npm -v
6.4.1

验证您的 npm 全局安装文件路径是否已配置(称为 prefix).我的在 ~/.npm-packages 下:

Verify your npm global install file path is configured (known as prefix). Mine is under ~/.npm-packages:

$ npm config ls -l | grep prefix
prefix = "/Users/christiangroleau/.npm-packages"

如果没有,你可以把它放到你的 ~/.npmrc 文件中:

If not, you can place it into your ~/.npmrc file:

echo prefix=~/.npm-packages >> ~/.npmrc

验证您的前缀路径是否列在您的系统路径中:

Verify that your prefix path is listed in your system PATH:

$ echo $PATH
/Users/christiangroleau/.npm-packages/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

如果没有,请调用以下内容:

If not, invoke the following:

export PATH="$HOME/.npm-packages/bin:$PATH"

最后,您可以重新安装 angular-cli(在我的情况下,我需要全局安装它):

Finally, you can reinstall angular-cli (in my case I needed to install it globally):

$ npm install -g @angular/cli

验证安装:

$ ng -v

这篇关于ng:找不到命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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