Netlify is not being recognized in Terminal

Viewed 2641

I have done npm install netlify-cli -g and this is successfully installed. I get the following response:

npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3. C:\Users\soyebp\AppData\Roaming\npm\ntl -> C:\Users\soyebp\AppData\Roaming\npm\node_modules\netlify-cli\bin\run C:\Users\soyebp\AppData\Roaming\npm\netlify -> C:\Users\soyebp\AppData\Roaming\npm\node_modules\netlify-cli\bin\run

netlify-cli@2.36.0 postinstall C:\Users\soyebp\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 Netlify 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\netlify-cli\node_modules\chokidar\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.36.0 updated 1 package in 22.697s

However when I try doing netlify, I get the following respone:

'netlify' is not recognized as an internal or external command, operable program or batch file.

If I go to:

C:\Users\soyebp\AppData\Roaming\npm\node_modules\netlify-cli

then it will work. However, I want to be deploying from other directories.

Any help would be greatly appreciated :)

1 Answers

The only reason why netlify is not working anywhere else is because it is not being recognized as an environment variable. You need to add the path to the environment variable, close the git bash and then run the netlify command again.

To add the netlify path to the environment variable, follow these steps:

  1. Search environment in the search box and choose Edit the System environment variables.

Environment variable search

  1. Click on Environment Variables... from System Properties dialog box.

Environment Variables

  1. In System Variables section, click on Path variable and click on Edit.

Environment Variables dialog box

  1. In the Edit Environment Variable dialog box, click on New and add the path C:\Users\{user}\AppData\Roaming\npm\ or C:\Users\soyebp\AppData\Roaming\npm\node_modules\netlify-cli, whichever works for you.

Add path

  1. Close git bash and run it again. Now type netlify and it should work. It will show output similar to this:

Netlify in git bash

Related