'nx' is not recognized as the name of a cmdlet

Viewed 15608

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.

5 Answers

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

Try first

npm install -g @nrwl/cli

try

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

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.

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

Related