Nest-cli: Nest : Command not found

Created on 28 Jan 2019  Â·  13Comments  Â·  Source: nestjs/nest-cli

I installed nestjs cli globally via npm command.
npm i -g @nestjs/cli .
Installation was successful.
But when I am trying to create new project via cli, it says
-bash: nest: command not found.
I moved to corresponding folder and tried nest new my-first-project command.

I feel like I am missing some configuration. Please help me here.

Current behavior

Unable to create a new Nest Project via CLI.
Using nest new my-project command

Expected behavior

New project should be created via CLI.

Minimal reproduction of the problem with instructions

1) Installed @nest/cli globally via NPM.
2) Moved to corresponding folder
3) Ran nest new my-first-project command
4) -bash: nest: command not found error observed.

Environment

Mac OS X El Capitan
Version : 10.11.6
Node version : 10.8.0
NPM Version : 5.3.0

Let me know if any further information is required.

Thanks in advance.

Most helpful comment

I was having the same problem on macOS Mojave, what I did was:
installed the latest node with npm install npm@latest -g

and then added the following to my .bash_profile
alias nest="/usr/local/Cellar/node/11.9.0/bin/nest"

Tested with nest --version and it worked.
For some reason the path is not being called correctly, hope it helps.

All 13 comments

See here https://github.com/angular/angular-cli/issues/503 (just keep in mind that you want nest, not ng command available globally)

Made some progress with this (on windows at least):
run npm root -g
that will take you to:
C:\Users\username\AppData\Roaming\npm\node_modules
then go back one directory to the npm directory and then (hopefully you have angular installed) copy and paste the both ng files and rename them nest.
Now point to the @nest directory - \@nestjs\cli\binnest.js
This gets me to the point where it wants to create the scaffolding but then it breaks with:
"C:\Users\usernameAppData\Roaming\npm\node_modules\@nestjs\cli\node_modules.bin\schematics

I don't know where the .bin file is. If anyone can improve this answer I'll be super grateful

I was having the same problem on macOS Mojave, what I did was:
installed the latest node with npm install npm@latest -g

and then added the following to my .bash_profile
alias nest="/usr/local/Cellar/node/11.9.0/bin/nest"

Tested with nest --version and it worked.
For some reason the path is not being called correctly, hope it helps.

Same issue on Windows with the version 6.13.3.

Edit:
Found a solution by upgrading to the latest version of Node (13.5.0) and npm (6.13.6).

I'm running into this as well. I have @nestjs/cli in a project with yarn, so I tried running it first with yarn nest --version which didn't work. I tested installing nestjs/cli globally and then running nest --version, which didn't work either. However, the workaround with setting an alias in my profile doesn't work, because I want to use the local version of nestjs/cli in my project, not a globally installed one.

Ran into the same issue because I'm trying to deploy to Elastic Beanstalk as a Node.js app and it fails on the build step with nest not found. Will use Docker to do it instead.

same issue
npm i -g @nestjs/cli
when i check
nest --version
it says
image

I ran into the same problem using oh my zsh with nvm and yarn. @yarapolana put me in the right direction but I had to add alias nest="~/.yarn/bin/nest" to the ~/.zshrc file.

Had the same issue today with oh my zsh and Ubuntu 20.04 LTS, and your answers gave me the solution. I had to check where the package was installed globally by yarn, so I had to run yarn global dir @nestjs/cli to get the directory for me to add an alias in my ~/.zshrc file.

Adding the alias into ~/.bashrc is not a solution. Ok, I can use nest command now, but I still can't create new nest app.
I try to use nest new <app-name> and nothing happens.

pplaczek@et0851:~/projects/nest$ nest new nest
âš¡  We will scaffold your app in a few seconds..

pplaczek@et0851:~/projects/nest$ 

Versions:

pplaczek@et0851:~/projects/nest$ nvm --version
0.34.0
pplaczek@et0851:~/projects/nest$ node --version
v12.14.1
pplaczek@et0851:~/projects/nest$ npm --version
6.13.4
pplaczek@et0851:~/projects/nest$ nest --version
7.5.1

Ubuntu 20.04 LTS

I had the same problem. It turned out the npm bin directory to the PATH like this:

export PATH="$PATH:/home/mbenitez/.npm/bin"

I did this in my bashrc file.

I had the same problem on MacOS Big Sur. I created symlink for nest command in /usr/local/bin/nest. It seems like:

ln -s /usr/local/Cellar/node/15.2.1/bin/nest /usr/local/bin/nest

Result:

macbook:~ smekalin$ nest -v
7.5.4

Hi. We can fix with that:
npm install -g @nestjs/cli

hope that useful.

Was this page helpful?
0 / 5 - 0 ratings