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.
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.
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:
- This will install the cli without listing it as a dependency in your
package.json
. - This will allow you to run
lb4 app
only in the root folder of project where you ran the command. - 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.
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.
I was also facing same problem. But then I ran the command using sudo and it worked. sudo npm i -g @loopback/cli
.
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)
© 2022 - 2024 — McMap. All rights reserved.