DEV Community

Koby
Koby

Posted on

How to solve Netfliy 'command not found' problem

Sometimes you get stuck on something which is supposedly really simple, but you can't figure out how to proceed.
I had to deploy a static site to Netlify. I opened an account and went ahead and installed the Netlify command line tool on my macbook. Thing is, while the terminal prompted me with an installation successful output, I couldn't run any Netlify commands. No matter what I tried I got a command not found.
Fortunately, it is easy to solve.
Good chances are that the problem is actually that you need to update your $PATH env to make Netlify and other packages accessible to you everywhere.
Here is how you solve it:

  1. (You probably already did this if you are here), install Netlify cli:

    npm install netlify-cli -g

    Now, pay close attention to the prompt you are receiving on your terminal. It will show the installation directory which you need to copy, and will look something like this:

    /Users/username/.npm-global/bin/ntl -> /Users/kobyofek/.npm-global/lib/node_modules/netlify-cli/bin/run
    /Users/username/.npm-global/bin/netlify -> /Users/kobyofek/.npm-global/lib/node_modules/netlify-cli/bin/run

    Specifically, you need to copy this part:

    /Users/username/.npm-global/bin/

  2. Now, we need to add that to our .bash_profile.
    How do we do that? Easy, fire up your vim editor and insert the following lines:

    export PATH=/Users/username/.npm-global/bin/:$PATH

    If you need to freshen up a bit on your vim skills, don't forget to use i to insert some text where your cursor is positioned and :x to save and quit.

  3. run the following:

    source ~/.bash_profile

    You should now be good to go and Netlify should be available for you in your terminal.

Top comments (0)