loopback "lb4" command is not working after successfully installation of loopback CLI using "npm i -g @loopback/cli"
Asked Answered
M

5

5

I have successfully installed loopback CLI using npm i -g @loopback/cli after that I'm trying to create app using lb4 app command terminal and it shows me Command 'lb4' not found. Only lb app works for version 3 and 2 but I want to create application compatible with loopback version 4.

Margiemargin answered 25/12, 2018 at 13:48 Comment(4)
this means your loopback is not installed properly, try to re-install it.Unchristian
I have successfully installed referring from official documentation link(loopback.io/doc/en/lb4/Getting-started.html) instructionsMargiemargin
and one more thing lb command works for both versions 3 and 2 but I want to create application compatible with loopback4. so, I'm trying to use lb4 command it's not workMargiemargin
I tried as given in official doc and lb4 worked fine. There might be some issue with npm in your case, please check if the package is getting installed globallyUnchristian
D
4

I had the same problem and solved it by updating to the latest version of Node.js (10.7 as of now). Then I reinstalled the LoopBack CLI with npm i -g @loopback/cli and the lb4 app command worked just fine. Also, I was executing all the commands as admin, in case it helps.

Doloresdolorimetry answered 21/1, 2019 at 19:59 Comment(2)
Note this is correct, but you do not have to be admin.Machiavelli
@nuria, Still not work, currently installed version of node is 10.16.2 and npm 6.5.0Margiemargin
C
3

If you're having trouble creating a global link on Windows 10 (like I did). Consider installing in the NodeJS project folder as a work-around.

Simply execute: npm install @looback/cli --no-save

Notes:

  1. This will install the cli without listing it as a dependency in your package.json.
  2. This will allow you to run lb4 app only in the root folder of project where you ran the command.
  3. This solution is not ideal since you'll have to do this for each project. However I figured it beats having to install a new version of NodeJS just for the installer to clear some cache/configuration that got messed up over a long time-period.
Carlin answered 3/10, 2019 at 14:12 Comment(0)
N
0

Upgrade your Node.JS to version 8.9 or higher. It's a Prerequisites. See the doc: https://loopback.io/doc/en/lb4/Getting-started.html#prerequisites

Also some time npm installs the JS module successfully but does not add in environment variable. Find the npm folder path (in my case C:\Users\user_name\AppData\Roaming\npm) and add into class path. After adding environment variable restart the command prompt.

Nappie answered 6/1, 2020 at 7:17 Comment(0)
T
0

I was also facing same problem. But then I ran the command using sudo and it worked. sudo npm i -g @loopback/cli.

Tory answered 28/7, 2021 at 12:32 Comment(0)
Q
0

sudo update-alternatives --install /usr/bin/lb4 lb4 /opt/nodejs/node-v19.1.0/bin/lb4 0

This command will be more useful to solve this problem. You can replace nodejs path according to your system.(/opt/nodejs/node-v19.1.0/bin)

Qualifier answered 16/2, 2023 at 16:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.