loopback "lb4" command is not working after successfully installation of loopback CLI using "npm i -g #loopback/cli" - node.js

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)

Related

Error: You need to specify a command before moving on. Use '--help' to view the available commands [duplicate]

Running windows 7 Professional 32bit.
I tried running npm install -g angular-cli both under normal or admin.
I also tried adding it to the Enviorment Variables under PATH: (C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng) , with no success also.
What am i doing wrong?
I solved this problem in accordance with the figure:
run in cmd
npm install -g #angular/cli
and then
( open in Windows 10) Control Panel\All Control Panel Items\System
or accordance with the figure
step 1:
step 2 :
step3:
step4:
step5: add missing ng path
Here is new environment variable that you need add: C:\Users\PK\AppData\Roaming\npm\node_modules\#angular\cli\bin
Finally, restart all opened command prompts and try again.
For me it works with:
npm run ng <command>
Adding C:\Users\DELL\AppData\Roaming\npm to System Variable Path worked for me. Please find your appropriate file path to 'npm'
Also, check if you have added your angular-cli\bin path to the path variable.
I am using WIN 10, just figure it out for this problem.
Type the code below in cmd:
npm config get prefix
and copy&paste the path that you get it from the top into your computer environment variables-->user variables box --> path --> edit -- C:\Program Files\nodejs\node_global, your path may different.
Click Ok and reopen your cmd window, type in ng version, then it works! Cheers!
Just open your command prompt (run as administrator). Ensure node --v is 6.9.0 or higher and npm --v is 3.0.0 r higher.
After that run the following command:
npm install -g #angular/cli
Once angular is installed. you can see an entry of angular cli in the path
C:\Users\Dell\AppData\Roaming\npm\node_modules\#angular
Then try ng help. It will work.
1) Enter below command on command prompt
npm install -g #angular/cli
2) Make sure that C:\Users\_username_\AppData\Roaming\npm this path is not hidden.
3) Add C:\Users\_username_\AppData\Roaming\npm and
C:\Users\_username_\AppData\Roaming\npm \node_modules#angular\cli\bin to both enviroment variable path.
4) Open new command prompt and type ng help. It will work.
With a command
npm install -g #angular/cli#latest
It works fine, I am able to run ng command now.
I solved it few days ago, after having the same problem with other global modules, by adding to:
Environment Tables -> System variables -> Path:
C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin;C:\Program Files\MongoDB\Server\3.2\bin
Note that it must not have any spaces after ;
That turned out to be my problem.
I followed below steps for resolution for this issue in Windows 10:
First make sure you have installed Angular CLI . You can use below
to install same.
npm install -g #angular/cli#latest
Make sure that AppData is visible and navigate to path below.
C:\Users\rkota\AppData\Roaming\npm
Same path can be found by running below too:
npm config get prefix
Add the above path i.e. " C:\Users\rkota\AppData\Roaming\npm" in Environment variable PATH and make sure it got added by running path in command prompt.
Close command prompt and now try to run below:
ng --version
you will be able to see CLI version.
execute following lines in order to solve the issue for both not found and undefined version of ng
npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli
npm cache clean
npm install -g #angular/cli#latest
Instead of using the in-built command prompt better start using the NodeJS installed version of command prompt. Then it is going to work perfectly without any issues.
General problem is that OS tries to find the PATH variable with ng keyword and cannot find it.
For me, even after the steps #behrouzmoslem suggested in the top answers to this post I didn't manage to get it work, because after the launch of ng command OS started to respond, but opens up editor file by the path C:\Users\{username}\AppData\Roaming\npm\node_modules\#angular\cli\bin\ng which is actually funny. So, solution is:
Just use npx before any angular executables.
Eg : npx ng serve for serving the angular app or npx ng build --watch to build with watcher.
If you get the error even after following the above step. then try below.
Since it is a node script. I am using the below option to create as of now.
node C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng version
May be symbolic links are required. Not researched further.
On Further Research:
Set Path as : %PATH%;C:\Users\Administrator\AppData\Roaming\npm;
In Windows, npm.cmd file is in the above path. If the above Environment variable is set, you can execute as
ng version
ng init
Open cmd and type npm install -g #angular/cli
In environment variables, add either in the user variable or System variable "Path" value=C:\Users\your-user\.npm-packages\node_modules\.bin
In cmd: c:\>cd your-new-project-path
...\project-path\> ng new my-app
or ng all-ng-commands
I resolved by adding - %AppData%\npm\node_modules#angular\cli\bin\ path to my environment variables path
close cmd and open it again with admin right or reboot ur system.
for me it works only with the flag --force:
npm install -g #angular/cli --force
If everything is fine then you shoud see the folder node_modules in this path:
C:\Users\YOUR_USERNAME\AppData\Roaming\npm\
I faced same issue when i tried to install angular cli locally with command
npm install #angular/cli#latest
After that i got same issue
C:\Users\vi1kumar\Desktop\tus\ANGULAR\AngularForms>ng -v
'ng' is not recognized as an internal or external command,
operable program or batch file
Than i tried to install it globally
npm install -g #angular/cli#latest
In this case it worked I was wondering that is it not possible to install cli globally ?
After doing some research I found this article very helpful hope it will help someone facing similar issue
Working with multiple versions of Angular CLI
This one almost worked for me, but I had to use: %USERPROFILE%\AppData\Roaming\npm
. In Environment Variables.../System variables/Path
Then when I did CMD: "ng -v" I got the correct response for angular cli.
npm install -g #angular/cli helped for me instead of npm install #angular/cli
1- Install
$ npm install -g #angular/cli
2- Make sure where your ng.cmd is present.
3- Then add this path into variables.
I had the same problem on Windows 7, 64 bits running with npm v3.10.8.
I added the path as it was suggested: ( C:\Users.....(your user name)\AppData\Roaming\npm\node_modules\angular-cli\bin\ng) and uninstalled angular-cli.
After this, I cleared the npm cache by npm cache clean as prompted here https://blogs.msdn.microsoft.com/matt-harrington/2012/02/23/how-to-fix-node-js-npm-permission-problems/. This guarantees there are no leftovers.
Reinstalled angular-cli with npm install -g angular-cliand voila.
Hope that may be useful!
In my case I did below steps.
All Programs -> Node JS-> Right click on Node.js Command Prompt and select properties and from Target string at end copy below
/k "C:\Program Files\nodejs\nodevars.bat"
I launched Visual Studio Code and opened below file
C:\Users\gochinta\AppData\Roaming\Code\User\settings.json and gave below
// Place your settings in this file to overwrite the default settings
{
"terminal.integrated.shellArgs.windows":
["/k", "C:\\Program Files\\nodejs\\nodevars.bat"]
}
Now I typed ng -v in my Visual Studio Code Terminal window and it worked.
I was having the same issue when tried with the syntax "ng new " and solved that simply by updating the existing node version from 5.x.x to 8.x.x. After successful updation of node, the syntax worked perfectly for me. Please update the existing version of node. As it is clearly mentioned in angular documentation that these commands require the node version >= 6.9.x. For reference please check https://angular.io/guide/quickstart. It clearly states "Verify that you are running at least node 6.9.x and npm 3.x.x by running node -v and npm -v in a terminal/console window. Older versions produce errors, but newer versions are fine".
I faced same issue on x86, windows 7;
uninstalled #angular/cli
re-installed #angular/cli
checked & verified environmental variables (no problems there)...
Still same issue:
Solution was the .npmrc file at C:\Users{USERNAME}... change the prefix so that it reads "prefix=${APPDATA}\npm"... Thanks to this website for help in resolving it
For me something was wrong in the PATH enviroment variable. I removed all path related to npm and added at the start of PATH this folder:
c:\Users\<your-user-name>\AppData\Roaming\npm\
Make sure you have ; between paths.
I am facing same issue and it's get resolved. At my end reason is i install node and CLI using other user profile and now i am running ng command from other user login. Since node and cli installed using other user login node is not finding anything on C:\Users\<user name>\AppData\Roaming this path and that's why i am getting this error.
I run npm install -g #angular/cli command and restart my machine. Every thing is working fine.
Sometime in the future. Applicable to Windows 8.1 machine.
Run the following commands
npm install -g #angular/cli
Log out or restart your machine.
This should add the required env path, rather than doing it manually.
I also tried to play with cmd by setting environment variable path & etc, but simple answer is use nodejs command prompt.
So you no need to set environment variable path or anything. When you insalled nodejs it will give it's command prompt, by using that you us "ng" command, without any settings.
Since this question is still asked over and over again one year later I will post my answer here as well.
The clue (on Windows only) is to arrange the entries in the path variable right.
As the NPM wiki tells us:
Because the installer puts C:\Program Files (x86)\nodejs before C:\Users\\AppData\Roaming\npm on your PATH, it will always use version of npm installed with node instead of the version of npm you installed using npm -g install npm#<version>.
So your path variable will look something like:
…;C:\<path-to-node-installation>;%appdata%\npm;…
Now you have two possibilities:
Swap the two entries so it will look like
…;%appdata%\npm;C:\<path-to-node-installation>;…
This will load the npm version installed with npm (and not with node) and with the installed Angular CLI version.
If you (for whatever reason) like to use the npm version bundled with node, add the direct path to your global Angualr CLI version. After this your path variable should look like this: …;C:\Users\<username>\AppData\Roaming\npm\node_modules\#angular\cli;C:\<path-to-node-installation>;%appdata%\npm;…
or …;%appdata%\npm\node_modules\#angular\cli;C:\<path-to-node-installation>;%appdata%\npm;…
for the short form.
This worked for me since a while now.

Installing Angular CLI with npm install fails

I am new to AngularJS, just started an online course.
I am trying to install angular CLI on my computer at work running Windows 7.
I opened command line as administrator and running npm install -g #angular/cli. Installation starts and after a few minutes I get an error:
I see the notification "operation not permitted", but I am the administrator of the computer and the command line I run as administrator.
What am I doing wrong?
The same installation I did on my laptop at home and it was successful.
I am checking with our IT support about other possible causes and will appreciate any help.
This is not a duplicate of Fail to install npm package “npm ERR! errno -4048” or npm install -g angular-cli fails.
Ignoring the error and running gn -v I get the following:
Is this correct? Was Angular CLI installed?
These issues are because of the company proxy settings.
Check with your admin to get the proxy for http or https.
It will be something like this:
http_proxy = http://http.myproxy.com:8000
https_proxy = http://http.myproxy.com:8000
Replace myproxy with the name of company proxy.
Then go to the command prompt and run the following command to set the proxy. Later you can run any command like npm install -g #angular/cli to run. It will work
npm config set proxy http://http.myproxy.com:8000
npm config set https-proxy http://http.myproxy.com:8000
That fsevents library has peculiarities on Windows. So I suggest you ignore the error message and run ng -v from the command prompt to confirm you got the Angular CLI libraries installed.
You need to run the npm commands on node.js command prompt but not on windows command line.
Workaround: install git bash on windows.
As the error message suggest, you don't have some permissions to execute your command.
Depending on your system, you should run the command as an administrator.
Also, don't mix AngularJS (the first Angular framework) and Angular (also known as Angular 2, 4 and 5 now) . They are radically different in their syntax and uses.
Run below command and try installing angular cli again.
npm cache clean -f
This worked for me manytimes.

Cmmand issue - "ng" command not recognized as internal or external even when is in PATH Environment Variable [duplicate]

This question already has answers here:
ng is not recognized as an internal or external command
(51 answers)
Closed 3 years ago.
For some reason, yesterday, all my commands (ng, npm, node, etc.) were working fine, but at night I cleaned my PC from trash files and all that (my pc has Windows installed), and now it doesn't recognize the ng command, but all the others are OK.
I checked the Environment Variables and its path is there, I checked the path, and it's all right, I re-installed with:
npm install -g angular-cli**
However, nothing happened. I rebooted the computer and all that, but I just can't get ng working again.
I ran into this same snafu when I was trying to install Angular (v4.0) correctly. The way I corrected it, after I incorrectly executed npm install #angular/cli -- which generated a directory called node_modules.
To correctly install angular with npm, remove the directory node_modules, then simply start a new bash shell or simply open a new console or terminal tab, and execute sudo npm install -g #angular/cli. This may prompt you for your machine's password, so be prepared to enter it without being able to see it.
It seems like you were following the Angular weblog's instructions for installing Angular v4. You can do that instead instead just as easily; The key to installing Angular v4 correctly on my machine (besides updating my nodejs installation to the prerequisite latest version), was using sudo with the -g (aka. global) option.
At the end I made it work, I had to uninstall even all my NodeJs, de #angular/cli and the angular-cli, Rebooted my computer and then reinstalling NodeJs latest version and installed Angular with npm install -g #angular/cli#latest and removed from PATH and Environment Variables the old paths and got it running fine!
For me (In Windows) the problem was that the npm path was not saved in the path environment variable. If you browse to
C:\users\yourname\AppData\Roaming\npm
Inside this directory you can see ng (a javascript file) and ng.cmd (the windows command file that executes the javascript file). This path needs to be in your path variable to be able to call ng

How can I get the slc command to work on Ubuntu?

I have installed Strongloop using npm install -g strongloop on my Ubuntu 14.04 server. The slc command does not work. It says
The program 'slc' is currently not installed. You can install it by typing:
sudo apt-get install heimdal-multidev
How can I get it to run the Strongloop CLI instead of looking for this package? I have added this to my PATH and it still doesn't work. Any ideas?
Other Strongloop commands, like sl-build work and strongloop is listed in npm list -g.
Ubuntu 14 with node.js 4.1.2
By default somehow slc is not created or not added to PATH.
I solved this problem by adding symlink:
sudo ln -s /usr/lib/node_modules/strongloop/bin/slc.js /usr/bin/slc
A soft link named slc should have been created at /usr/local/bin which will point to strongloop binary.
Please verify if the following exists.
/usr/local/lib/node_modules/strongloop/bin/slc
If no, then strongloop did not get installed successfully, otherwise verify the existence of the softlink slc at /usr/local/bin/.
/usr/local/bin/slc -> /usr/local/lib/node_modules/strongloop/bin/slc
If yes, then /usr/local/bin needs to be added to the $PATH, otherwise create the softlink and verify that /usr/local/binin $PATH.
Looks like the Node installation that optionally comes with a Digital Ocean Droplet installs to a different location that's not in $PATH. I'm pretty sure that was the issue. Anyways, I fixed it by spinning up a server without Node pre-installed and followed this guide. Just use npm install -g strongloop instead of strong-cli because the latter has been deprecated.
Ubuntu 14.04 with node.js 4.4.2 (LTS) :
The installation of strongloop was done without any errors but slc was not added to the PATH. I solved this problem by adding the symlink:
sudo ln -s /usr/local/lib/node_modules/strongloop/bin/slc.js /usr/bin/slc
Actually i am not sure my case matches with yours but i want to share my experience. i got the same message anyway.
I realized that i had changed prefix of global packets before. Then i checked prefix with the following command.
$ npm config get prefix
/home/myUser/.node_modules_global
Then i added the path to PATH variable (but .profile, .bash_profile files will be better) in active command line window and problem solved.

'Express' is not recognized command (windows)

Okay I am running node on windows (7). Using npm I just installed modules to d:\ directory. Therefore my files structure looks like the following:
D:\
-myproject
-node_modules
-.bin
-express
However, when I am in this 'myproject' directory, I can't seem to run 'express' for example:
D:\myproject\express site
'express' is not recognized as an internal or external command, operable program or batch file.
Am I doing anything wrong?
Try:
npm install -g express-generator#3
That solved problem for me.
Edit: for version 4
npm install express-generator -g
Description:
express is the package for dependency of express js.
express-generator is the package for enabeling express command and create a sample project, etc.
Assuming that this is kept separate for the decoupling of project dependency with cli tool of express.
Another SO ref: https://stackoverflow.com/a/41311733/1666582
Here's what to type in the command line to make it work in windows:
npm install express-generator -g
[Source: http://expressjs.com/starter/generator.html]
My guess is that you didn't install Express globally. You can install express globally (and therefore available in your PATH) with the following command (see http://expressjs.com/guide.html) :
npm install -g express
The way you install it is available only in the folder that you installed it and there is nothing wrong with that approach. There is very little advantage of having it available globally.
If express is not in your PATH you can run it by entering the full path to it:
\myproject\node_modules\.bin\express.cmd
With the release of Express 4.0.0 it looks like you need to do
npm install -g express-generator
We need to set path for express global directory
C:\Users[User_Name]\AppData\Roaming\npm\
After add a new path, please reopen the CMD console
Tried all of these and never worked. A repair of Node.js by kicking of installation and selecting repair option does the magic.
Cheers
What worked for me was:
I used the windows command prompt instead of the node.js command prompt.
In windows 10 simply type in the windows search bar for "node"
You see a node.js desktop app and a node js command prompt.
Choose the "node js command prompt"
Type in the command prompt
npm install express-generator -g
Then navigate somewhere and type in:
express your-website-text-here -e
A directory with express files will be generated. Also now you won't see the express error.
I was able to fix with the following package install:
npm install express-generator -g
Thanks
When you install Node.js, the below path is added to the Windows OS %Path% variable, I'm presuming similar happens on other operating systems as well:
C:\Users\<your-windows-username>\AppData\Roaming\npm
In my case, because I use a work Windows laptop for an employer that severely restricts what employees can do on their machines (I.e. many actions require elevated admin privileges), Node.js was being prevented from adding the above path to the Windows %Path% environment variable, and much to my chagrin the Node.js installation was silent about it. Navigate to above folder and you will notice the express command lives there, see screenshot below.
How did I figure this out? I did a fresh installation of Node.js on a personal, home Windows machine that has no admin privilege restrictions like my work machine does, compared the before and after %Path% value, and noticed the addition of that path. My work machine was missing it.
I had no choice but to add the path manually to %Path%, and then express was recognized from within any path I ran it.
I was able to fix this with:
npm install express-generator -g
I tried all the above solution, no luck for me.
Open "Node.js" command prompt and tried as administrator. It is working fine for me. Don't try with windows command prompt.
I have the same problem and understand the solution, but i can´t undestand why, running npm install -g express, express.bat isn´t added automatically to Path.
Running with npm install -g express have the same result. Download packages and store in node_modules, but express.bat isn´t added to path.
Run the node command prompt as administrator and then install express globaly
npm install -g express
and then go to folder where you want to install express generator, open command prompt there and run this command
npm install express-generator, it will then fix the issue
I have tried out all above solutions, but its did't worked for me, finally I have re-installed the node.js with newer version and started to express install process again. Its worked for me.
npm install -g express
npm install -g express-generator
What command are you using to open the directory?
That error means CMD can't find the "express" executable in the current directory.
Use the "PUSHD" command or "CD /D" instead of "CD"
#Echo OFF
PUSHD "D:\myproject\express" || (Echo bad folder)
express.exe "site"
Pause&Exit
Express is loaded someplace else and not in the windows path environment variable. You need to find were express.exe is installed and add the path. Maybe something like ;"C:\Program Files\Express\bin";
Running "npm install express" and "npm install express-generator" from your project directory will resolve the issue (if that helps).
But, this doesn't solve the problem of being global.
You might check the permissions to the folder if you are getting this when creating your project
Express Project
change script section in package.json file like this
"scripts": {
"start": "node app.js"
}
I too faced the similar problem and at last I tried using node.js command prompt instead of windows command prompt and it worked. So, try from node.js command prompt.
Tried all of these but didn't work for me. Also, I tried from different sources but never worked for me.
In the end, found that I need to run the command forcefully. It worked for me.
Make sure you run the command with Run as Administrator.
npm install -g --force express-generator
It will overwrite the existing express files.
Use npm start .. then the app.js runs .. which can be listened on the usual port 3000

Resources