I'm trying to install Hexo globally using npm. When I run
npm install -g hexo-cli
I'm informed that it was installed to /Users/myusername/.node/bin/hexo -> /Users/myusername/.node/lib/node_modules/hexo-cli/bin/hexo
The problem comes in when I run hexo init blog
and the hexo command is not found.
I installed Node and npm with Homebrew, so when I run which node
and which npm
, the results are /usr/local/bin/node
and /usr/local/bin/npm
respectively.
I'm thinking that I still have leftover files and directories from when I installed Node without homebrew, but I don't want to start deleting things without fully knowing the repercussions. Would I be safe to delete all files located in the /Users/myusername/.node/
directory? I can't figure out why npm is not installing to the proper directory.
js documentation and found that it can be changed very easily using a simple "npm config" command. For example: npm config set prefix "E:\node_modules", From the next time onward, every global installation will save the node modules in "E:\node_modules" folder.
Path of Global Packages in the system: Global modules are installed in the standard system in root location in system directory /usr/local/lib/node_modules project directory. Command to print the location on your system where all the global modules are installed.
The global packages will be installed under the active Node version lib/node_modules folder. The $HOME variable points to your user directory in the system. You can also use the where nvm command to find your NVM installation location.
Also, if you want to check if the particular package is installed globally or not, you can hit the below-mentioned “npm list -g” command followed by the package name that you want to check.
After a little digging, I found that my npm prefix variable was pointing do the wrong directory, left behind by the old Node installation. I ran npm config get prefix
to see where it was pointing.
I set the new prefix value using npm config set prefix /usr/local
. Homebrew is symlinked with this directory via /usr/local/bin
. I uninstalled hexo-cli and reinstalled through npm, and now it works perfectly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With