After npm install -g, command still not found?
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)
Related videos on Youtube
neaumusic
Updated on September 18, 2022Comments
-
neaumusic over 1 year
I don't know what's going on, but none of my installed node packages are actually registered.
npm
andnode
work fine, but if Isudo npm install -g
ffmpeg
orbrew
, they're listed at/usr/local/lib/node_modules
butbrew -v
andffmpeg -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
andbrew
... Does npm symlink to the command line, or only allowrequire("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
-
Fabian von Ellerts almost 5 yearsI can confirm this is working on macos High Sierra, thank you!
-
CTN about 4 yearsStill facing same problem.
-
theferrit32 about 3 years
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
.