'I can't install nestjs in ubuntu 20.04
I'm using Ubuntu 20.04 LTS and I was trying to install nestjs to study but... well, it's better to show what happened
first I tried to discover which version of my npm or node was, that was the result:
$ npm - v
output: 6.14.16
$ node -v
output: v14.19.1
theoretically I can install nest, right? well, I ran this code:
$ npm i -g @nestjs/cli
output: /home/user/.npm-global/bin/nest ->
/home/user/.npm-global/lib/node_modules/@nestjs/cli/bin/nest.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/@nestjs/cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ @nestjs/[email protected]
updated 1 package in 17.045s
I figured that this output seemed weird, even so I tried to discover if nest was installed
$ nest -v
output: Command 'nest' not found, did you mean:
command 'newt' from snap newt (0.0.1)
command 'net' from deb samba-common-bin (2:4.13.17~dfsg-0ubuntu0.21.04.1)
command 'next' from deb mailutils-mh (1:3.7-2.1)
command 'next' from deb mmh (0.4-2)
command 'next' from deb nmh (1.7.1-6)
command 'test' from deb coreutils (8.30-3ubuntu2)
command 'nast' from deb nast (0.2.0-7build1)
command 'neat' from deb neat (2.2-1build1)
command 'nes' from deb fceux (2.2.2+dfsg0-1build1)
command 'nes' from deb mednafen (1.22.2+dfsg-1build1)
command 'nes' from deb nestopia (1.50-1build1)
See 'snap info <snapname>' for additional versions.
I'm really new in this development 'and this is my first post here!' world but I appreciate your attention in my problem (also I'm not from USA so my English might be with lots of mistakes, sorry!)
Solution 1:[1]
There are two way to solve your issue:
- Use npx before every nestjs command:
npx @nestjs/cli g controller pages
Add an alias inside your .bashrc or .zshrc (depend which one you are using):
To find your node path, type in your terminal:
which node
or
which nodejs
Then, when you have your path to node:
alias nest="/your/path/to/node/bin/nest"
Then in your terminal you can test
nest --version
It should work
Solution 2:[2]
I noticed you're currently on a older version of Node Package Manager (npm) and you need to upgrade it before you can install stuff like nest.js... So these are the steps
Step 1. clean cache with this command, then you will get a message " I sure hope you know what you are doing" if you're on the track
sudo npm cache clean -f
Step 2. Install Node’s version manager
sudo npm install -g n
Step 3. install a stable version
sudo n stable
The stable version is ok, but you can install that latest version as well with sudo n latest.But i hope you don't have another challenge eventually
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gianfabio Pezzolla |
| Solution 2 | Ekama Emmanuel Uloho |
