8

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

1 Answer 1

17

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)

3
  • I can confirm this is working on macos High Sierra, thank you! Commented Jul 12, 2019 at 12:37
  • Still facing same problem.
    – CTN
    Commented Feb 20, 2020 at 13:56
  • npm install -g is not adding links to $prefix/bin, each executable is separated into their own package's install directory like $prefix/lib/node_modules/$package/bin/. When -g is not used, npm does add a convenient link directory of executables ./node_modules/bin. Commented Mar 3, 2021 at 16:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .