Netlify: command not found

I successfully ran npm i -g netlify-cli on Git Bash (I’m running on Windows 10), but when I run netlify or any netlify commands, I get bash: netlify: command not found.

I opened a new terminal window, and even restarted my laptop, both to no avail.

I then tried searching this forum as well as Google, but (to my surprise) didn’t seem to find anyone experiencing this issue.

Any suggestions?

Hi @msandula

Have you verified that netlify-cli has actually been added to the global modules folder (%APPDATA% \npm\node_modules)

Cheers, Ben

Yes.
C:\Users\{ USER }\AppData\Roaming\npm\node_modules\netlify-cli

hmmm that’s odd…Do other commands work such as node --version?

Yes.
My Node version is v10.15.0.
My NPM version is 6.4.1.

have you tried removing the package globally and re-adding it?

I hadn’t before, but did just now – still having the same issue :weary:

are you using nvm by any chance?

No, I am not using nvm.

have you tried executing the command with npx? e.g npx netlify init

1 Like

Same result: bash: netlify: command not found.
(Thanks for the help so far, by the way; much appreciated)

well this is getting weirder and weirder…have you tried a different terminal? I’m actually running out of ideas :slight_smile:

hey there, did you restart your machine after the entry was added to your PATH? Sometimes that is necessary for the entry to be re-read.

I would also recommend a different terminal, such as powershell, and seeing if you can run the command there.

Yes – though I restarted again just for grins. Tried PowerShell too; no dice. I’m at a loss.
‾_(ツ)_/‾

Hi, @msandula. Would you run the install command again? When it runs look for output similar to this (which will obviously differ on Windows):

/home/user/.nvm/versions/node/v11.8.0/bin/ntl -> /home/user/.nvm/versions/node/v11.8.0/lib/node_modules/netlify-cli/bin/run
/home/user/.nvm/versions/node/v11.8.0/bin/netlify -> /home/user/.nvm/versions/node/v11.8.0/lib/node_modules/netlify-cli/bin/run

> netlify-cli@2.32.0 postinstall /home/user/.nvm/versions/node/v11.8.0/lib/node_modules/netlify-cli
> node ./scripts/postinstall.js


Success! Netlify CLI has been installed!

Next test using the full path to the CLI tool. This might look similar to this:

$ /home/user/.nvm/versions/node/v11.8.0/bin/netlify version
netlify-cli/2.32.0 linux-x64 node-v11.8.0

This will confirm that the Netlify CLI tool is installed and working. If that works, the final step to resolve the issue will be to add the directory which contains this link to your bash environment variable PATH.

Here is the PATH environment variable for the system used in the examples above:

PATH="/home/user/.nvm/versions/node/v11.8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/share/rvm/bin:/usr/local/bin/"

If there are other questions about this, please let us know.

This is what I get after Step 1. Step 2 gives me the same ol’ command not found.

$ npm i netlify-cli -g
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not r                       ecommended for usage due to the number of issues. Please, upgrade your dependenc                       ies to the actual version of core-js@3.
C:\Users\msand\AppData\Roaming\npm\netlify -> C:\Users\msand\AppData\Roaming\npm                       \node_modules\netlify-cli\bin\run
C:\Users\msand\AppData\Roaming\npm\ntl -> C:\Users\msand\AppData\Roaming\npm\nod                       e_modules\netlify-cli\bin\run

> core-js@2.6.11 postinstall C:\Users\msand\AppData\Roaming\npm\node_modules\net                       lify-cli\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfill                       ing JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Colle                       ctive or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a goo                       d job -)


> core-js@3.6.4 postinstall C:\Users\msand\AppData\Roaming\npm\node_modules\netl                       ify-cli\node_modules\log-process-errors\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"


> netlify-cli@2.32.0 postinstall C:\Users\msand\AppData\Roaming\npm\node_modules                       \netlify-cli
> node ./scripts/postinstall.js


Success! Netlify CLI has been installed!

Your device is now configured to use Netlify CLI to deploy and manage your Netli                       fy sites.

Next steps:

  netlify init     Connect or create a Netlify site from current directory
  netlify deploy   Deploy the latest changes to your Netlify site

For more information on the CLI run netlify help
Or visit the docs at https://cli.netlify.com

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\net                       lify-cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@                       2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}                       )

+ netlify-cli@2.32.0
added 1029 packages from 482 contributors in 62.454s

It appears to have installed here:

C:\Users\msand\AppData\Roaming\npm\netlify

If you cd into that directory (C:\Users\msand\AppData\Roaming\npm\) and run ./netlify version while there, does it still say “command not found”?

If I cd into C:\Users\msand\AppData\Roaming\npm\ and run `./netlify version’, I get:

netlify-cli/2.32.0 win32-x64 node-v10.15.0

But if I run netlify in that same directory, it still tells me bash: netlify: command not found.

Hi, @msandula, the solution for this will be to add this path (C:\Users\msand\AppData\Roaming\npm\) to the PATH environment variable for this shell.

I believe there is an explanation of how to do this here:

If that doesn’t resolve the issue, please let us know.

Heyyyy, that finally did the trick!

Thank you so much! Appreciate the help from everyone.

1 Like