Global Node Packages Installed in the Wrong Directory

I am trying to install Hexo globally using npm. When I run    npm install -g hexo-cli I was informed that it was installed on/Users/myusername/.node/bin/hexo -> /Users/myusername/.node/lib/node_modules/hexo-cli/bin/hexo

The problem occurs when I run hexo init blogand the hexo command is not found.

I installed Node and npm using Homebrew, so when I run which nodeand which npm, the results are /usr/local/bin/nodeand /usr/local/bin/npmrespectively.

I think that I still have the remaining files and directories when I installed Node without homebrew, but I do not want to start deleting things without knowing the consequences. Will I safely delete all files in a directory /Users/myusername/.node/? I can not understand why npm is not installed in the appropriate directory.

+4
source share
2 answers

After a little digging, I found that my npm prefix variable indicated the wrong directory left by the old Node installation. I ran npm config get prefixto see where he was pointing.

I set a new prefix value with npm config set prefix /usr/local. Homebrew is symbolically linked to this directory via /usr/local/bin. I uninstalled hexo-cli and reinstalled it via npm and now it works fine.

+10
source

An easy way to deal with environment variables / path issues in Windows:

Launch command:

npm install -g hexo 

Using node.js command line , not cmdwindows provided by Windows itself.

0

All Articles