How can I install npm in laravel 5.4? - laravel

When I use this command in command mode:
D:\xampp\htdocs\profileApp>npm run dev
I get this error:
'npm' is not recognized as an internal or external command, operable
program or batch file.
How can I solve this?

First of all, I assume you are a Windows user. In this case, you need to download and install NPM together with NodeJS from the official website. When installing, do not unselect the "Add to PATH variables" point. It's important that NPM is added to your PATH variables, so it's globally available.
After installing, simply restart your terminal(s)

Download and install Gitbash it will be used to run such commands. `
Git bash will help you emulate bash commands. Read this article with how to use git and npm on windows with Git Bash

First you need to install Node which comes with NPM bundled in so that it would be recognizable by Windows CMD you can download the latest version from the Official Website.
Optional : If you are willing to work on open source projects consider
installing Git for windows

Related

Git Bash npm package commands not found

I have recently installed Vue-cli globally via npm on Git Bash. However, when I run vue, I get C:\Users\[User]\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found. I'm not an expert at bash, but I'm pretty sure that the PATH isn't set up correctly. But if I run env|grep PATH I can see C:\Users\[User]\AppData\Roaming\npm in my path.
However if I run vue on my basic cmd, it works as intended. Is there something that my git bash is missing? Also, if I run npm config get prefix I get C:\Users\[User]\AppData\Roaming\npm.
Note that I used Vue as an example. I get the same error when running create-react-app.
I have the latest version of git bash (2.28.0) and on Windows 10.
Terminal emulator installed by git is named Mintty. To run npm with Mintty, you need to add the path to an environment variable.
Add the following line to your ~.bash_profile file. If it does not exist, create it
When Mintty starts up it will read .bash_profile. You should now be able to run npm
These other questions might be helpful also.
https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path https://askubuntu.com/questions/58814/how-do-i-add-environment-variables

Packages installed from admin cmd/powershell not added to PATH for regular cmd/powershell (foo not recognized...)

I'm trying to globally install a package that has to be installed from an administrative cmd/powershell (it uses windows-build-tools). When I install it using an administrative powershell, everything works fine - the install runs with no errors, and the command line interface of the package is added to the path:
PS C:\WINDOWS\system32> npm install -g prisma
C:\Users\XXX\AppData\Roaming\npm\prisma -> C:\Users\XXX\AppData\Roaming\npm\node_modules\prisma\dist\index.js
+ prisma#1.34.0
added 588 packages from 448 contributors and updated 1 package in 23.005s
PS C:\WINDOWS\system32> prisma --version
Prisma CLI version: prisma/1.34.0 (windows-x64) node-v10.9.0
When I try to access the command line interface from a regular cmd/powershell though, the name of the package is not recognized:
C:\Users\XXX>prisma --version
'prisma' is not recognized as an internal or external command,
operable program or batch file.
What do I do to ensure that packages installed from an administrator command line are accessible to the regular command line?
Alexey Ivanov answered a similar question a while back, and his answer would help you here. Specifically, the following:
It's worth to mention that NODE_PATH is only used when importing
modules in Node apps. When you want to use globally installed modules'
binaries in your CLI you need to add it also to your PATH, but without
node_modules part (for example %AppData%\npm in Windows 7/8/10).
For that last bit, if your module was installed in "%AppData%\npm\node_modules" your path would include "%AppData%\npm".
Net-net, this isn't a Powershell issue. Its an issue with the package you're installing.
And, if you want a little insight into creating a CLI package, checkout the piece by Rubens Mariuzzo A guide to creating a NodeJS command-line package:
While on Windows, npm will do the same (only if the shebang is
specified) but will also create a {command-name}.cmd that calls node
to execute our specified command file.
Running Windows 10.0.17763, and I was able to install ‘prisma’ via npm (6.9.0), and I can access it from new console sessions. I was able to do the install both from an elevated and unelevated session w/same result.
Here is what my path looks like after the install:

ng is not recognized as an internal or external command

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.

Bower can only see git path on gitBash, not in cmd (windows)

Apologies if this is wrong format of question: my issue is resolved in another post but I'm hoping for help on understanding the why.
I've been trying to run
bower install
through the command line as administrator on Windows 8, and I get the error
bower ENOGIT git is not installed or not in the PATH
However, other "git..." commands in the same window work fine (Git's /bin/ and /cmd/ have been added manually to the system-level path). As per the helpful suggestion at https://stackoverflow.com/a/21444065/4477927 , running bower install at the same location through git bash - rather than windows cmd - works fine.
So although my problem is solved I'd like to improve my understanding of the tools by knowing why the git command works when typed manually, and can be invoked by bower through git bash, but cant be invoked by bower through cmd?

git is not installed or not in the PATH

Windows, when I try to run npm install, it shows:
mean#1.0.0 postinstall E:\mean
node node_modules/grunt-cli/bin/grunt install
Running "bower:install" (bower) task
Fatal error : git is not installed or not in the PATH
npm ERR! weird error 1
npm ERR! not ok code 0
What is the problem? How to fix it?
The project git repository is https://github.com/linnovate/mean
Did you install Git correctly?
According to the Bower site, you need to make sure you check the option "Run Git from Windows Command Prompt".
I had this issue where Git was not found when I was trying to install Angular. I re-ran the installer for git and changed my setting and then it worked.
From the bower site:
http://bower.io/
while #vitocorleone is technically correct. If you have already installed, there is no need to reinstall. You just need to add it to your path. You will find yourself doing this for many of the tools for the mean stack so you should get used to doing it. You don't want to have to be in the folder that holds the executable to run it.
Control Panel --> System and Security --> System
click on Advanced System Settings on the left.
make sure you are on the advanced tab
click the Environment Variables button on the bottom
under system variables on the bottom find the Path variable
at the end of the line type (assuming this is where you installed it)
;C:\Program Files (x86)\git\cmd
click ok, ok, and ok to save
This essentially tells the OS.. if you don't find this executable in the folder I am typing in, look in Path to fide where it is.
Installing git and running npm install from git-bash worked for me. Make sure you are in the correct directory.
Install git and tortoise git for windows and make sure it is on your path, (the installer for Tortoise Git includes options for the command line tools and ensuring that it is on the path - select them).
You will need to close and re-open any existing command line sessions for the changes to take effect.
Then you should be able to run npm install successfully or move on to the next problem!
In my case the issue was not resolved because i did not restart my system. Please make sure you do restart your system.
If you installed GitHubDesktop then the path for git.exe will be ,
C:\Users\<'Username'>\AppData\Local\GitHubDesktop\app-1.1.1\resources\app\git\cmd
Add this path to the environment variables by following,
** (Note: \cmd at the end, not \cmd\git.exe).**
Navigate to the Environmental Variables Editor and find the Path variable in the “System Variables” section. Click Edit… and paste the URL of Git to the end. Save!
Now open a new cmd and type command git. If you are able to see the git usage then it's done.
Now you can execute your command to install your package.
ex: npm install native-base --save
Use Git CMD instead of using Win CMD.
I did install git and tried again and got the same error. But running 'npm install' in a new command prompt window worked for me. Restarting the machine is not required.
Go to Environmental Variables you will find this in Computer Properties->Advance system Setting->Environmental Variables -> Path
Add the path of your git installed int the system.
eg: "C:\Program Files\Git\cmd"
Save it.
Good to go now!!
The issue depends on the command prompt you are using. if you are using your Windows cmd, then it will be fine if you have installed git in your system (note that after installation it gets added to your system path). if you are running on an Anaconda terminal or any other, then you need to install git on your project environment from the terminal.
for anaconda, the problem gets solved by running:
conda install git

Resources