'nest Command not found
I followed the documentation to create my first NestJS project.
Installing the Nest CLI with the command npm i -g @nestjs/cli
was successful.
The output was:
+ @nestjs/[email protected]
updated 1 package in 11.326s
However, when I try to scaffold a project with the Nest CLI:
nest new project-name
I get the following error:
zsh: command not found: nest
Some details about my environment:
- OSX
- iTerm
- npm version 6.5.0
Solution 1:[1]
Use npx @nestjs/cli
instead of nest
e.g. npx @nestjs/cli g controller pages
Solution 2:[2]
I was also getting the same console error when npm installing!
Erro was
@nestjs/cli
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2. npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@nestjs/cli npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@nestjs npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":"<8.10.0"} (current: {"node":"12.14.1","npm":"6.13.4"}) npm WARN notsup Not compatible with your version of node/npm: [email protected]
How I wasn able to install => Solution
sudo npm install -g @nestjs/cli
Solution 3:[3]
I was having the same issue, 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.
Solution 4:[4]
Following command works in my windows 10
node -v
v14.16.0
npm -v
6.14.11
npx @nestjs/cli new project-name
Solution 5:[5]
Working through a NestJS/Mongo DB tutorial i stumbled into this very same problem. After trying all of the solutions that were listed above, even turning my default profile back to bash instead of using zsh, i found that simply adding the /usr/local/bin and ~/.npm-global/bin to my path variable resolved the issue. Hopefully this helps someone else who may stumble on this in the future as well.
export $PATH="/usr/local/bin"
export $PATH="~/.npm-global/bin"
Were the two commands i ran from iTerm2 in order to add them to my PATH environment variable. Once this was done a simple
env
showed the entries in my $PATH environment variable and the nest -v
command worked without any issues.
Solution 6:[6]
You have to add the following line to your ~/.zshrc
file:
source $HOME/.bashrc
This is needed so that the npm binaries are available on startup.
Solution 7:[7]
I had same error when I use GitBash. I resoved it: If you use windows: Your use CMD: npm i -g @nestjs/cli
Then you can use gitbash:
- Check version nestjs: nest --version
- Create app nestjs: nest new name_project
Solution 8:[8]
I have faced same problem and solved ,following this
- write the command
NPM root -g
- check where NPM is installed
- add it to your path environment variable
Solution 9:[9]
After all the answers that I tried, I used my method
After installing
npm i -g @nestjs/cli
in my mac terminal.open bash file in macos by typing
open ~/.bash_profile
in mac terminal. Like you can type it anywhere.Your bash will look like this and use this line
alias nest="~/.npm-global/lib/node_modules/@nestjs/cli/bin/nest.js"
Restart your mac for changes to be reflected in your terminal.
There you go nestjs cli is now working globally 2nd screenshot.
Solution 10:[10]
You can try to use sudo
sudo yarn global add @nestjs/cli
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow