-2

I'm a noob at my wits end and have already consulted a couple of friends who know (much) more than me. Sorry if these are dumb questions. Hoping you guys can help.

I think it has to do with some weird NPM pathing issues, but I can't figure them out. npm install -g generator-xxx follows through with success, but when I run Yo, no generators are listed.

Tried npm update -g npm - no dice. Npm remains out of date. This is also true of n and most (but not all? I think?) npm modules.

I tried to start from scratch, followed NPM's advice for a complete fresh start. Reinstalled node from node.js's website. Happily, node is up to date, but npm is still several released behind (2.11.3).

The most disturbing part of all of this: npm uninstall -g npm and the packages still work, which makes me think I've got a rogue npm installation rumbling around somewhere in my box, but I cannot find it.

Thanks in advance for your time and consideration!

Zach Herring
  • 354
  • 2
  • 10
  • What paths do you get from `npm root -g` and either `which -a npm` (terminal) or `gcm npm` (PowerShell)? – Jonathan Lonowski Jul 12 '15 at 02:59
  • @JonathanLonowski `/Users/zachherring/.node/lib/node_modules` and `/usr/local/bin/npm` respectively. – Zach Herring Jul 12 '15 at 03:18
  • You appear to have multiple installations of npm, with one executing (in `/usr/local`) and updating the other (in `~/.node`) rather than itself. Or, at least, `npm` [is configured](https://docs.npmjs.com/misc/config#npmrc-files) to work on the latter path. – Jonathan Lonowski Jul 12 '15 at 03:28
  • 1
    Ah. Do you have any resources you might be able to point me to to rectify this? How can I find both installations and/or fix the pathing? Thanks again. – Zach Herring Jul 12 '15 at 03:33

1 Answers1

2

Node loads modules from several locations by default, and is also influenced by your environment. Take a look in these locations to see if you have modules installed that you weren't aware of.

  • $HOME/.node_modules
  • $HOME/.node_libraries
  • <prefix>/lib/node_modules (where <prefix> is e.g. /usr or /usr/local
  • Any path(s) in the $NODE_PATH environment variable
  • ./node_modules if it exists in the current directory
  • ../node_modules if it exists
  • ... and so on up the tree, all the way to the root of the filesystem
Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
  • `npm list -g` - is this a list from _all_ of those locations or just `USERNAME/.node/lib/` ? I've checked where you've listed - none of those locations existed except the `.node/lib` location. Thanks! – Zach Herring Jul 12 '15 at 03:23
  • `npm list -g` should list global modules only, which I am guessing in your case are under `$HOME/.node/lib`. `npm list` without the `-g` flag will look at local modules, e.g. those found in say `./node_modules` relative to your current path. – Dan Lowe Jul 12 '15 at 04:10