nodejs
nodemon: Command not found after installed globally
2021-07-04
This blog post is a trouble shooting for the error, "command not found" after installing nodemon globally. No more sudo-ing in your command-line!
Hi there! I'm Arisa, a DevRel Engineer at Storyblok.
Sometimes, when you try to install nodemon package, it shows you this error message.
zsh: command not found: nodemon
Even if you try to install nodemon with sudo
, it returns the same error. Also, using sudo
command is the least option you want to take.
What do we do?
Yarn with prefixing file path solves the "command not found" issue
I tested with just installing nodemon globally without prefixing the file path first. But it fails with the same error log.
Luckily, we can find nodemon installation example in yarn's documentation.
yarn global: https://classic.yarnpkg.com/en/docs/cli/global/
As I failed without configuring the file path, let's configure the file path this time as we can see in their documentation.
$ yarn global add nodemon --prefix /usr/local
# --prefix [filepath] is necessary
$ which nodemon
$ /usr/local/bin/nodemon
Let's try to command nodemon😎
$ nodemon app.js
Tada〜🎉
Summary
You'll find a lot of questions from people in Stackoverflow but the best way is to go to the documentation without hitting sudo
command for everything.
Hope you found something useful in this blog post!
Tscüß👋