A lot of people have this problem but it always starts out with "I installed NVM for windows and now NPM won't work". That is not my issue. NPM works fine. My problem is with installing packages, but I should prefix this by saying that I'm new to npm, git, etc so I may be missing something.
I've been handed a DOMO project and I was instructed to install this ryuu package to the app's local node_modules directory -- but that I need to use NVM to switch between node versions (not sure if that's their requirement or best practice, seems like the latter). Regardless, I install NVM, and install the version of node required by the .nvmrc file - and when I go to install the ryuu package it downloads locally to the node_modules directory as expected.
The problem is when I run the domo login
command -- 'domo' is not recognized
. I can see the executable script in the app's local node_modules/.bin directory though. Yet, when I install the package globally, it installs in appdata/roaming/nvm/<node version>
/node_modules and when I run the command domo login
, I get a message saying:
[ERROR] The domo cli tool has experienced an error. As it is
[ERROR] possible this bug has already been fixed, please try updating
[ERROR] using `npm install -g ryuu` and run this command again. If this
[ERROR] does not fix the issue, please contact your MajorDomo.
[ERROR] error message: Unexpected token {
I'm assuming this package is broken or NVM is messing with it, but it seems I've successfully hit the global executable script.
When I run npm root
I see it points to the local node_modules directory but when I run nvm root
it points to the appdata/roaming path. My best guess is that NVM is looking in the wrong place (global) to execute the (local) domo script, but I'm not sure how to change that path.
I looked at environment variables, and there is one pointing to a nodejs directory in C:/Program Files but it is a symlink for the current version of node that NVM is using, and it goes right back to the appData/Roaming directory which I understand to be the way it *should work. I also believe this is why I can execute globally installed packages but not local ones, and why NPM works (because it is installed globally).
So, how do I tell NVM to look in the app's local node_modules directory instead of the global one, or can this not be done? I read that NVM for windows is not the same as NVM, so this may be one of those variances in how it works?
==========================================================
EDIT:
Just in case anyone sees this, I haven't solved the root cause of this issue, but I have found a way around it.
If you cd into the app's local directory, then in the terminal you can run any script command by doing
node_modules/.bin/<scriptname> command