Search code examples
npmfish

fish shell and global npm modules


I'm experiencing some issues with my local environment.

I'm using:

  • homebrew (1.1.4)
  • fish shell (2.4)
  • n version manager (2.1.0)
  • node
  • npm

All of the above were initially installed via homebrew.

Issues:

  • Any globally installed modules cannot be run.
  • I cannot update npm versions.

The node versions I use regularly are 0.10.48 and 6.9.2 - but mostly 4.6.2.

I've created some aliases in fish to be able to get the the global modules to run. I'd prefer to address the root cause rather than continue applying further bandaids though.

Extra info:

~> npm config get prefix
/Users/me/.npm-packages

~> npm bin
/Users/me/node_modules/.bin

What happens when I try to update npm:

~> npm install -g npm@3
/Users/me/.npm-packages/bin/npm -> /Users/me/.npm-packages/lib/node_modules/npm/bin/npm-cli.js
npm@3.10.10 /Users/me/.npm-packages/lib/node_modules/npm
~> npm -v
2.15.9

When I try to call a global module:

~> gulp
fish: Unknown command 'gulp'

What I've tried in order to fix the global modules:

~> cat ~/.config/fish/config.fish
set fish_user_paths /Users/me/.npm-packages

ls ~/.config/fish/functions
bower.fish ember.fish pm2.fish

~> cat ~/.config/fish/functions/bower.fish 
function bower
    /Users/me/.npm-packages/bin/bower  $argv;
end

Any help you can provide will be greatly appreciated! I've been trying to fix this for awhile now without any luck!


Solution

  • I resolved this by completely uninstalling (and deleting any traces of) node, npm and n, uninstalling fish shell and changing to zsh instead.

    Afterwards, I installed nvm and used it to restore node on my machine.

    Global npm modules now work.