Rekoolno
Rekoolno

Reputation: 85

bash: ngc: command not found

I'm using @angular/compiler-cli to build my ng2 app in aot mode. When I input 'ngc -p tsconfig-aot.json' in my bash window, I get 'bash: ngc: command not found'. However, when I use 'node_modules/.bin/ngc -p tsconfig-aot.json' instead, it works. I googled for serval times but didn't get any usfull information. Can any give me a hand? Thx!

Upvotes: 4

Views: 8409

Answers (4)

funder7
funder7

Reputation: 1829

To run commands located into the node_modules folder of your project, without installing them globally (operation that will make the ngc command work in any system folder), you can use this command:

ngx ncc <options>

Basically ngx is a shortcut that executes any command located in node_modules bin folder.

Upvotes: 0

Camilo Pati&#241;o
Camilo Pati&#241;o

Reputation: 181

I've tried to change the slash to 'backslash' on windows and it worked for me:

node_modules\\.bin\ngc

Upvotes: 1

Jan Clemens Stoffregen
Jan Clemens Stoffregen

Reputation: 887

If you don't want to set it globally, you can specify an absolut path in your angular-project, just make sure that you delete this part of the path when you don't use it anymore.

ngc is in node_modules/.bin, so depending on where you want to use ngc you can export the path like this:

PATH=$PATH:../../../node_modules/.bin

Upvotes: 0

Farhad Farahi
Farhad Farahi

Reputation: 39327

Seems like you need to put ngc in your path:

echo $PATH

Do you see ngc in binary in your path?

If not:

PATH=$PATH:/path/to/ngc

To make it permanent add to .bash_profile

export PATH=$PATH:/path/to/ngc

Upvotes: 4

Related Questions