2

I have looked at a lot of answers on here and I'm still not able to figure this one out. I am attempting to learn node again, but after my global install of nodemon (which completed successfully) I am getting command not found: nodemon when running nodemon app.js. A while back I moved my npm path to /Users/mlefkowi/npm-global for some reason. When I echo $PATH, that directory does not exists. This is what I get:

/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

I have been able to add it to the $PATH, but when I close out Terminal it doesn't save. Should I move npm back to it's default directory? How can I get a path to save to $PATH?

lfkwtz
  • 1,007
  • 2
  • 11
  • 25

1 Answers1

2

Edit your ~/.bashrc and add the following line:

export PATH="/Users/mlefkowi/npm-global:$PATH"

This assumes that /Users/mlefkowi/npm-global/nodemon is the path to the nodemon executable. If it's in a bin sub-directory off of npm-global, then change /Users/mlefkowi/npm-global to /Users/mlefkowi/npm-global/bin.

.bashrc is sourced every time your shell starts up, so this modification will stick for all new terminal sessions. After editing it for the first time, run source ~/.bashrc to update your PATH for that session.

hansod1
  • 314
  • 1
  • 4
  • I just ran **nano ~/.bashrc** and added **export PATH="/Users/mlefkowi/npm-global:$PATH"** to it (it is the only entry). The file is saved as **/Users/mlefkowi/.bashrc**. I then ran **source ~/.bashrc** and then **echo $PATH** and it was there. I then closed the terminal window, and ran **echo $PATH** again, and it's gone. But, the line is still in my **/Users/mlefkowi/.bashrc** file. What did I do wrong? – lfkwtz Mar 09 '16 at 19:36
  • Your `.bashrc` should be run every time you open a new terminal. When you closed the terminal window, did you open a brand-new terminal window to test? – hansod1 Mar 09 '16 at 19:47
  • This is probably relevant to you: http://stackoverflow.com/questions/7780030/how-to-fix-terminal-not-loading-bashrc-on-os-x-lion I use iTerm, so it's possible that the default terminal uses `.bash_profile` instead. – hansod1 Mar 09 '16 at 19:49
  • Would it be easier to just change my npm install back to the default? Then my $PATH would already include the necessary paths, correct? – lfkwtz Mar 09 '16 at 21:20
  • Tried the top two solutions in that link, neither are working – lfkwtz Mar 09 '16 at 21:27
  • Alright I just reset my default directory and it's working now. – lfkwtz Mar 09 '16 at 21:36