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.

ranjit redekar
  • 919
  • 1
  • 12
  • 24
  • 1
    this means your loopback is not installed properly, try to re-install it. – Varun Sukheja Dec 25 '18 at 13:52
  • I have successfully installed referring from official documentation link(https://loopback.io/doc/en/lb4/Getting-started.html) instructions – ranjit redekar Dec 25 '18 at 14:12
  • 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 work – ranjit redekar Dec 25 '18 at 14:18
  • 1
    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 globally – Varun Sukheja Dec 25 '18 at 19:49

5 Answers5

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.

Nuria
  • 61
  • 1
  • 2
  • 6
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.
Byebye
  • 934
  • 7
  • 24
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.

Pravin Kumar
  • 331
  • 1
  • 6
0

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

Sudhir
  • 312
  • 1
  • 4
  • 10
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)