Reputation: 69
I have installed node.js in my computer. I can check the node and npm version in my cmd. I am using laravel homestead with vagrant in windows 10. however. When I use git bash the node version is shown buy the npm is not recognized returning a message saying npm: command not found.
I do appreciate any help.
Upvotes: 6
Views: 23780
Reputation: 7036
The error above happens when the Windows operating system doesn’t know what to do with the npm command.
To fix the error, you need to make sure that the Node executable file is available under your PATH setting.
Note: NodeJS should have added the executable location to your PATH variable during installation process, but sometimes it may fail to do so.
You can add new entry to the Windows PATH environment variable using the Command Prompt as follows:
> SET PATH=C:\Program Files\Nodejs;%PATH%
> npm
Upvotes: 0
Reputation: 2303
Assuming you have both Git and Node.js with npm installed on your system, make sure that git and node are installed within a same directory of your Application. Eg:
App
|-git
| |-git_bash.exe
| |-etc
| |-profile
| |-node_env.conf
|-node
|-node
|-npm
Make sure node and npm are inside the node directory in App. Look at the example tree above.
open git bash and type:export PATH=$PATH:/c/App/node
After exporting the node directory in your App, now check if the npm is installed by: npm --version
.
If you want to configure this when launching your terminal, open the node_env.conf
file and pass in the node directory path by: PATH=$PATH:/c/App/node
Now open the profile git bash file at C:\App\git\etc\profile
and add source "etc/node_env.conf"
Now go ahead and clone some git repo and test it.
git clone your_git_repo
npm install
npm run watch
Upvotes: 1