Punt Speedchunk
Punt Speedchunk

Reputation: 613

Global Node Packages Installed to Wrong Directory

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.

Upvotes: 11

Views: 12389

Answers (3)

HNipps
HNipps

Reputation: 513

For NVM users

Run nvm use --delete-prefix v10.13.0 --silent replacing v10.13.0 with whatever version of node you're using.

Upvotes: 0

Xinyi Li
Xinyi Li

Reputation: 1012

A simple way to cope with environment variables/path problems on Windows:

Run command:

npm install -g hexo 

Using node.js command prompt rather than cmd windows provided by Windows itself.

Upvotes: -2

Punt Speedchunk
Punt Speedchunk

Reputation: 613

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.

Upvotes: 46

Related Questions