Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sounisi5011 opened this issue May 24, 2023 · 2 comments · Fixed by #5
Closed

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

sounisi5011 opened this issue May 24, 2023 · 2 comments · Fixed by #5

Comments

@sounisi5011
Copy link
Collaborator

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) {
@sounisi5011
Copy link
Collaborator Author

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

@andreynering
Copy link
Member

Hi @sounisi5011,

Yes, a PR would be helpful!

sounisi5011 added a commit to sounisi5011/go-npm--fixing-bug that referenced this issue May 24, 2023
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.
> --- https://github.com/npm/cli/blob/1e977eec223463b04a6ad2c1953e31a6d5d22f2c/docs/lib/content/configuring-npm/folders.md?plain=1#L55-L57

This pull request fixes a bug that did not conform to this behavior.

Closes go-task#4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants