Loopback-next: lb4 command not found

Created on 1 Jul 2019  Â·  21Comments  Â·  Source: strongloop/loopback-next

Description/Steps to reproduce

I installed loopback version 4 with the command npm i -g @loopback/cli (on Mac OS).When I try to create an app using the command lb4 app its throwing me an error lb4 command not found

Expected result

Should be able to create an app

CLI

All 21 comments

Open a new instance of the terminal program and try.

@rajsmly143 What did you install? npm i -g loopback-cli or npm i -g @loopback/cli? The later is for lb4.

Open a new instance of the terminal program and try.

I restarted my mac also, still facing the same issue.
image

What did you install? npm i -g loopback-cli or npm i -g @loopback/cli? The later is for lb4.

I used npm i -g @loopback/cli

same issue here

@rajvarshu and @devpato , are you using nvm to install node?
Could you please also try to run node -v? Thanks.

Transferred to loopback-next repo, because this is the repo for LB4.

i am still facing same issue

It seems like we're having a hard time to reproduce the problem, so I'd like to get more information from those who ran into this issue. Here are a few questions I have in mind (feel free to provide as much information as you have!):

  1. are you running nvm for managing the node version you're running?
  2. what's the node version? (run node -v)
  3. which OS are you using?
  4. Do you get command not found error? or other error?
  5. Did you install @loopback/cli at the global level? i.e. npm i -g @loopback/cli.

Thanks a lot.

I am getting the same problem. Please find below the answers to your questions:-

  1. are you running nvm for managing the node version you're running? No
  2. what's the node version? (run node -v) 10.16
  3. which OS are you using? Ubuntu 18.04
  4. Do you get command not found error? or other error? Command 'lb4' not found
  5. Did you install @loopback/cli at the global level? i.e. npm i -g @loopback/cli. Yes

@aneekbasu, do you have /usr/local/bin on your $PATH?

I don't have an Ubuntu instance handy to try, here are a few issues that i found that might be useful. Could you please check them out?
https://github.com/strongloop/loopback/issues/281
https://github.com/strongloop/loopback/issues/2737
https://stackoverflow.com/questions/20934343/how-to-restore-reset-npm-configuration-to-default-values

Hope it helps.

BTW, I strongly recommend that you use https://github.com/nvm-sh/nvm so that multiple node versions can be installed and isolated on your machine.

I am facing this issue too. npm install -g @loopback/cli

  1. I am using NVM
  2. Node: v10.15.3
  3. MacOS - Mojave
  4. NVM: 0.34.0

â–¶ lb4 app
zsh: command not found: lb4

I fixed the issue. I am using NVM but on digging into the issue further, I realized that though my current version is v10.15.3, my packages were getting installed in v8.x.x. I don't even have v8.x.x version installed but .npmrc was pointing to that folder. I deleted that folder, created a new npm prefix pointing to the current version and voila, it worked.

@rashtay What was in your .npmrc? For nvm, it needs to be activated with a new terminal window after the installation. Run command -v nvm to make sure.

@raymondfeng nvm was working fine. Unfortunately, it was installing global packages in the folder of a different version of the node. I deleted that folder from .nvm and fixed the prefix.

Now, .npmrc points to the right node version

prefix=/Users/rahshett/.nvm/versions/node/v10.15.3

This is almost certainly a PATH issue for everyone. I had /usr/local/opt/node@8/bin on my path for some reason. Changing it to /usr/local/opt/node/bin solved the issue for me. In fact, node@8 no longer even existed.

For others, you may need to google what your path should look like for node stuff.

  1. are you running nvm for managing the node version you're running? No
  2. what's the node version? (run node -v) v12.10.0
  3. which OS are you using? macOS 10.14.6
  4. Do you get command not found error? or other error? zsh: command not found: lb4
  5. Did you install @loopback/cli at the global level? i.e. npm i -g @loopback/cli. Yes
  1. macOs 10.13.6 (17G8030)
  2. Yes
  3. Yes
    Screen Shot 2019-09-21 at 3 05 05 PM

Screen Shot 2019-09-21 at 3 05 49 PM

It has been a while since I've touched NodeJs. So I may have something in my terminal incorrectly listed.

Solved

In my case, installed using the command:

$ sudo npm install -g @loopback/cli

It not worked:

$ lb4
-bash: lb4: command not found

But it worked by path:

$ /usr/local/opt/node/bin/lb4 app
? Project name: (projects)

I created an alias in .bash_profile:

alias lb4="/usr/local/opt/node/bin/lb4"

And now working fine:

$ lb4 app
? Project name: (bayma) 

nvm: No
node version: v12.14.1
macOS: 10.14.6
error -bash: lb4: command not found

@baymabruno Thanks a lot, great hint!
That happend to me because i installed nodejs on Mac with Brew command on user A now everithing i do about npm or whatever has to be done on that User and other users don't recognize the installation... well... looks like i finally have an scuse to format the MAC :)

@baymabruno, thanks for your info!
I'm now closing this issue. Thanks.

Was this page helpful?
0 / 5 - 0 ratings