How to make npm re-set PATH for half-installed mod

2019-08-27 15:35发布

问题:

I'm sure this title is unclear, but perhaps my explanation will help.

I had originally installed nodejs on my Windows7 laptop. I had also done "npm install -g" for some modules, like "karma", which resulted in the "karma" script being available globally. I reference "karma" from at least one build script in my Eclipse workspace on the Windows7 laptop. I'm running Cygwin on Windows7, so the shell script on Windows works fine.

(I note that referencing karma "globally" means that I can call it from anywhere, but it will only do anything useful if my current directory has a "node" or "node_modules" folder.)

I now have a Linux VM running on the laptop, and I can reference the host filesystem. I've installed all the obvious tools on the VM, including Maven and NodeJS. When I run my Maven build that references "karma", it fails because it can't find "karma".

What is the proper thing to do at this point, so I can reference "karma" globally on the VM? I could conceivably just copy the "karma" script that npm put into my "AppData/Roaming/npm/karma" folder on Windows, and put that into my $HOME/bin folder on the VM. This looks like it would work, but if there's an "automatic" way to fix this that is preferred, I'd like to do that instead of relying on manual patching.