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

查看:1191
本文介绍了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全局安装文件路径是否已配置(称为前缀) .我的在〜/.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

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

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天全站免登陆