nodemon command not found in git bash - node.js

I am trying to run my node.js app in Git bash terminal. It worked before every time I type nodemon server.js. Recently, I upgrated my node.js and npm. If I try to run my app on Git Bash again, an error of
C:\Users\PC\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found
Shows up.
I tried uninstalling and installing nodemon with npm install -g nodemon, and reinstalled git, the error still persists. Although, nodemon works fine on windows cmd terminal.
It would be nice to make it work on Git Bash terminal.

it actually comes down to the place you installed the Nodemon tool.
most people will install it in their working directory but i found that this way is not a safe bet. you should install it in the root directory as it will not cause trouble once you try to use it in another project.

Also facing the same issue! But I found a way around using npx nodemon script.js
Although I found the problem. Git bash is trying to execute nodemon from this directory: C:\Users\username\AppData\Roaming\npm/node_modules/node/bin/node
But in this path nodemon doesn't exist.
The path should be C:\Users\username\AppData\Roaming\npm\node_modules\nodemon

Related

npm and other modules commands not working

Note: I am on Windows 10 64 bit running the latest LTS Node build.
It all started when I tried running the command npm i -g create-react-app and I get a message saying that npm is not a command.
I checked my PATH and I believe I have the proper directories in there.
I navigated to the directory of npm and tried running the command again, but it still didn't work. I found that the command npm.cmd worked in any directory. So tried running npm.cmd i -g create-react-app and that worked! I also had to use the the command create-react-app.cmd my-app, instead of create-react-app my-app. I thought I was set and I could just use those .cmd commands for the things I needed to do; however, when I tried to run the command create-react-app.cmd my-app and got this as a result:
I have looked in the file that is ran when using this command create-react-app.cmd my-app and there is no sign of npm being called. Turns out Node is being called in that file with the command below. I know this because when I run it by itself and I get the same output to the console seen in the previous image.
"node" "C:\Users\Allen\AppData\Roaming\npm\\node_modules\create-react-app\index.js" my-app
it was called in the create-react-app.cmd file like this "%_prog%" "%dp0%\node_modules\create-react-app\index.js" %*
I am at a loss. I could continue down this rabbit hole and try and find the node file that is calling npm and change it to npm.cmd but I would rather find a way to get the npm and create-react-app commands working as they are suppose to. At the very least I can just spin up a VM and work in that. It is just annoying that I can't get Node to work properly for me.
Use the command npx create-react-app my-app this will help you create react projects.
Also check the documentation : https://reactjs.org/
First check that you have npm installed on your machine and the version. You can just type npm version. Since npm version 5.2.0 npx is pre-bundled with npm, which is a CLI tool whose purpose is to make it easy to install and manage dependencies hosted in the npm registry. So try using npx create-react-app app-name. You can confirm that you are able to use npx by running which npx. If it is not available then you can install it by running npm install -g npx.

npx requires re-installation of packages every time

Currently using npx as a workaround for packages installed globally by npm as commands can never be found despite all attempts at exporting to the correct path.
npx works in finding the command but has to reinstall the package every time to find it which means multiple uses of the same package runs into problems.
I've tried using the npx --no-install but then npx runs into the same problem as I did with "command not found" being the result.
All this is attempted through the ubuntu terminal.
Solved my issue. The npx workaround was never going to work when my npm pathing was acting up. Had to reinstall npm (again) and manually create a global directory rather than use the default. Then had to export that path variable and append it to .bashrc confirm it with "source /.bashrc" and then restart the terminal. On restart everything worked fine and had no further problems with npm installs.

bash: create-react-app: command not found (pretty sure it's my $PATH)

Let me preface by stating that this is my first post, and also I can’t retrace my steps to where the create-react-app command no longer works in my Terminal. Last week, when I was practicing how to work with ReactJS I was able to use the command create-react-app and had been able to initialize a React project. However, I’ve been fiddling plentifully with NodeJS and NPM stuff simultaneously, and now when I call the create react-app command this is the output:
bash: create-react-app: command not found
I’m pretty sure it has to do with my $PATH, however I’m not experienced with making edits through vim
when editing my .bash_profile. In my attempts to diagnose and fix the problem, here is what I appended to my $PATH through vim:
export PATH="/usr/local/bin:$PATH"
Nevertheless, I know the order of $PATH matters, but I’m naive as to whether I should prepend or append the $PATH above?
Here is what is output when I echo $PATH:
/usr/local/heroku/bin:/usr/local/bin:/usr/local/sbin:~/bin:/Users/bjornjohnramos/.rbenv/bin:/Users/bjornjohnramos/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/bjornjohnramos/.npm-packages/bin/express
-> /Users/bjornjohnramos/.npm-packages/lib/node_modules/express-generator/bin/express-cli.js:/Users/bjornjohnramos/.npm-packages/lib:export
PATH="/usr/local/bin:$PATH":export
PATH=$PATH:/Users/my_name/.npm-packages/bin/
my node and npm versions:
node v6.9.1
npm 4.2.0
Who knows what happened? But maybe we can just fix it by reinstalling...
npm uninstall create-react-app
npm uninstall create-react-app -g
npm install create-react-app -g
The first two commands will uninstall create-react-app locally and globally. (Not sure how you may have installed it. Harmless to run both.) The third installs globally, and should set up the path for you as needed.
use command npx create-react-app my-app rather than using npx create-react-app my-app that will resolves your bash: create-react-app: command not found err on windows.
Hope this is helpful
Happy coding...

angular-cli installs but ng command is not recognized

It happens that when I install angular cli, it gets stuck at
this point
I have looked for any solution , install/uninstall node.js and tried to use different versions of node and npm with no success.
EDIT: After uninstalling node.js, erasing npm folder in appdata, and reinstalling again, it installs but it does not recognize the ng command as shown here
It seems it is a path issue. This solution helped me fix it on macOs High Sierra.
npm install -g #angular/cli
Make sure the ng path is correct
cd ~/npm-global/bin
ls and make sure ng exists
create .bashrc file on your home directory
touch ~/.bashrc
vim ~/.bashrc
Add ng as alias
press i (enables edit mode) then type in the following
alias ng="~/npm-global/bin/ng" (or wherever your ng directory is)
press esc (to get out of edit mode) then :wq (in vim will save)
Temporarily Update .bashrc reference
Your terminal wont take bash updates until a restart but the following command will let you use the updates during the terminal session:
source ~/.bashrc
Check that ng works
ng --version
Found it from https://github.com/angular/angular-cli/issues/5021
May be try using ng commands with node.js cli (Node.js command prompt). It might work. I'd the same problem Here.
It happens that your node.js and angular visions are not compatible.
After the install and remove all the node files from on your pc.
then try these commands.
Install node.js package manager stable version.
After the install you run npm install
npm install -g #angular/cli 04 ng new <project name>
cd <your project location>
ng serve
(If it's still not working, again npm install and ng serve)
If this is still not working, provide a sample of the .json file in your question.

Nodemon installed but can't be found

I've tried uninstalling and and reinstalling nodemon several times both locally and globally with:
npm install -g nodemon
(tried it both with and without sudo)
and it seems to install no problem, and gives me:
/usr/local/bin/bin/nodemon -> /usr/local/bin/lib/node_modules/nodemon/bin/nodemon.js
/usr/local/bin/lib
└── nodemon#1.11.0
but whenever I run
nodemon server.js
in my app, I get;
-bash: nodemon: command not found
Like I mentioned, I've tried the same process but installing locally to my app dependancies, but it doesn't seem to make a difference. What's going on here? I followed the same process on a different machine, and it worked no problem.
Googling around, I came across some posts that mentioned changing/adding the PATH? But it's not clear to me if that's or the problem or what that means.
Also, other globally installed npm modules run just fine
nodemon is not being found by bash.
Edit your ~/.bash_profile file and add:
PATH=$PATH:/usr/local/bin/bin/
Start a new shell to see it work, or run source ~/.bash_profile to have it apply to the current session.
Instead of using sudo switched as root and then just run:
$ npm install -g nodemon
sudo su -
export PATH=$PATH:/home/USER/npm
npm install -g --force nodemon
# THESE LINES + START FROM A NEW TERMINAL...
# IN MY CASE
npm install -g --force node-inspector
# TOO

Resources