go-task/go-npm

BUG: On Windows, binaries are installed in the wrong location

Closed this issue · 2 comments

On Windows, the globally installed CLI is placed in the {npm_config_prefix} directory, not the {npm_config_prefix}/bin directory.

When in global mode, executables are linked into {prefix}/bin on Unix, or directly into {prefix} on Windows. Ensure that path is in your terminal's PATH environment to run them.
--- folders | npm Docs

However, the current installation logic seems to always install in the bin directory:

go-npm/src/common.js

Lines 41 to 43 in 5b4b644

if (env && env.npm_config_prefix) {
dir = join(env.npm_config_prefix, 'bin');
} else if (env && env.npm_config_local_prefix) {

I think this code needs to be fixed like this:

       if (env && env.npm_config_prefix) {
-        dir = join(env.npm_config_prefix, 'bin');
+        if (process.platform === 'win32') {
+          dir = env.npm_config_prefix;
+        } else {
+          dir = join(env.npm_config_prefix, 'bin');
+        }
       } else if (env && env.npm_config_local_prefix) {

If this is granted, I would like to create a pull request to reflect this fix.

Hi @sounisi5011,

Yes, a PR would be helpful!