I am trying to run ng build
in my project folder, but I get the following response:
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?
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"
}
}
In case others come here with this issue as I have, here is how I solved it system-wide on MacOS. Hope this helps.
Verify node is installed:
$ node -v
v11.2.0
Verify npm is installed:
$ npm -v
6.4.1
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"
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"
Finally, you can reinstall angular-cli (in my case I needed to install it globally):
$ npm install -g @angular/cli
Verify installation:
$ ng -v
try to uninstall and clean the cache.
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli
npm
doesn't recognize ng
command.
Try this command:
npm link @angular/cli
to link npm
and angular-cli
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With