24

I am trying to add a new util library into my Nx mono repo. I googled and found the following command from www.nx.dev:

nx generate @nrwl/nest:library util/util-myLibName

When I run the above command, then I get the following message:

The term 'nx' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I searched the web a lot, but couldn't find the solution.

R. Richards
  • 24,603
  • 10
  • 64
  • 64
Mohsen
  • 971
  • 2
  • 11
  • 29

6 Answers6

28

Tried the below command on Windows and it worked:

npm install -g nx

https://nx.dev/getting-started/nx-setup

Karthik
  • 931
  • 2
  • 9
  • 14
23

This is because the nx don't installed in your s.o

Try first

npm install -g @nrwl/cli

Felipe Antunes
  • 346
  • 3
  • 3
6

try

npx nx generate @nrwl/nest:library util/util-myLibName
Allure
  • 513
  • 2
  • 12
6

Instead of: nx serve

Do: npx nx serve

because npx is a package runner that can execute any package that you want from the npm registry without even installing that package.

Otherwise you can install nx package by using the following command:

npm install --location=global nx

3

I ended up running from the local package file:

./node_modules/.bin/nx

Migration example: ./node_modules/.bin/nx migrate latest

I did this because installing @nrwl/cli globally did not work for me.

mrshickadance
  • 1,213
  • 4
  • 20
  • 34
0

Here you need to install npm install -g @nrwl/cli and this will fix all.

Happy Coding !!!

Basavaraj SK
  • 245
  • 3
  • 3