Reputation: 51
I am trying to create a library in Angular using nx g @nrwl/angular:lib shared
but it keep giving me error zsh: command not found: nx
. All I did was before just create a angular project.
I try using this: npm install -g nx
so maybe it install nx
and it works, but I still keep getting the same error.
How can I fix this? I am using Mac. If any questions or information needed please feel free to leave the comment down below.
Upvotes: 26
Views: 68451
Reputation: 73
Try remove node_modules and reinstall dependencies via
npm install
or
yarn install
this works for me
Upvotes: 0
Reputation: 175
Try this: Install it globally by below command 100% will work
sudo npm i -g @nrwl/cli
remove -g if you don't want to install globally.
Upvotes: 12
Reputation: 17048
Do we really need to install @nrwl/cli
?
Just installing the nx
resolve the issue for me
sudo npm install -g nx@latest
Upvotes: 17
Reputation: 45
Installing the nrwl cli globally should do the trick, you'll need to enter the super user mode to do it.
sudo npm i -g @nrwl/cli
Alternative solutions can be found on the guide on the Nx Website here
https://nx.dev/l/a/tutorial/01-create-application
Upvotes: 2
Reputation: 126
Either you don't have refreshed your zsh
paths, which can be fixed by opening a new terminal or type
rehash
in the prompt.
If this doesn't work then nx
isn't globally installed on your machine. You have to type
npm run nx [your command]
instead of just "nx
" to use it, so in your case:
npm run nx -- g @nrwl/angular:lib shared
Sources: https://nx.dev/latest/angular/cli/overview#installing-the-cli
Upvotes: 11