Home > Mobile >  I can't install nestjs in ubuntu 20.04
I can't install nestjs in ubuntu 20.04

Time:03-22

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!)

CodePudding user response:

There are two way to solve your issue:

  1. Use npx before every nestjs command:
  npx @nestjs/cli g controller pages
  1. 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

  • Related