After npm install -g, command still not found?

4

4

I don't know what's going on, but none of my installed node packages are actually registered.

npm and node work fine, but if I sudo npm install -g ffmpeg or brew, they're listed at /usr/local/lib/node_modules but brew -v and ffmpeg -v don't do anything "command not found"

Any help is much appreciated, I'm pretty new with command line stuff. I think I'm confused on the difference between npm and brew... Does npm symlink to the command line, or only allow require("brew") within node instances?

One time, I did follow some instructions for registering "sublime" as a command line alias. Don't really think that should affect anything, but I don't even know where to look

neaumusic

Posted 2016-05-28T05:30:14.073

Reputation: 163

Answers

10

Is there anything displayed if you run npm get prefix ? (For example's sake, I'll say "/usr/local" is returned after running the command)

If anything is returned after running the above command, check what your PATH environment variable is set as by running echo $PATH (Again for example's sake, I'll say "/usr/bin:/bin:/usr/sbin:/sbin" is returned after running this command)

If the prefix returned from npm get prefix is not shown in your PATH – which is true for the example above since "/usr/local/" is not in PATH – you will then have to set your PATH variable. To set your PATH:

If your shell is Bash, run: export PATH="[prefix]/bin:$PATH" >> ~/.bash_profile where [prefix] is the returned value of npm get prefix

So, using "/usr/local" again as the example, replace "[prefix]" with "/usr/local" as shown below
export PATH="/usr/local/bin:$PATH" >> ~/.bash_profile
then do
source ~/.bash_profile

(You said you are pretty new to command-line stuff, so if this does not make much sense, leave a comment and I will try to provide further clarification)

cryptic

Posted 2016-05-28T05:30:14.073

Reputation: 126

I can confirm this is working on macos High Sierra, thank you! – Fabian von Ellerts – 2019-07-12T12:37:51.610

Still facing same problem. – CTN – 2020-02-20T13:56:56.920