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

FEATURE-REQUEST: PNPM support #2

Closed
mheob opened this issue Nov 14, 2022 · 4 comments · Fixed by #3
Closed

FEATURE-REQUEST: PNPM support #2

mheob opened this issue Nov 14, 2022 · 4 comments · Fixed by #3

Comments

@mheob
Copy link

mheob commented Nov 14, 2022

It would be nice to use this nice tool also with PNPM as package manager.

@andreynering
Copy link
Member

Hi @mheob,

I'm not familiar with pnpm. What is needed to support it?

@mheob
Copy link
Author

mheob commented Dec 2, 2022

Hi @andreynering.

Sorry, I missed your reply.

PNPM uses a non-flat and symlinked node_modules structure which offers many advantages. More and more projects and companies are switching to pnpm. E.g. vercel with next.js and other projects, just to name one of the big ones.

The details are a bit complex to explain for me. Therefore I would like to refer to the official documentation.

The error I am getting by using go-npm with pnpm looks like:

$ pnpm install

Lockfile is up to date, resolution step is skipped
Already up to date

 > use-correct-pm@1.0.4 postinstall /Users/mheob/dev/tools/use-correct-pm
 > is-ci || go-npm install

Downloading from URL: https://github.com/mheob/use-correct-pm/releases/download/v1.0.4/use-correct-pm_1.0.4_darwin_amd64.tar.gz
Error: Error finding binary installation directory
    at /Users/mheob/dev/tools/use-correct-pm/node_modules/.pnpm/@go-task+go-npm@0.1.16/node_modules/@go-task/go-npm/bin/index.js:2:909476
    at ChildProcess.exithandler (node:child_process:420:5)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1091:16)
    at Socket.<anonymous> (node:internal/child_process:449:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:313:12)
 ELIFECYCLE  Command failed with exit code 1.

So it appears to me that the bin directory cannot be found, although it is there (it can be checked via pnpm bin).

$ pnpm bin
/Users/mheob/dev/tools/use-correct-pm/node_modules/.bin

I hope this explanation helps a bit.

@andreynering
Copy link
Member

Thanks for the explanation.

If anyone wants to give this a try, we probably need to check for the right ENVs for pnpm here:

go-npm/src/common.js

Lines 36 to 42 in 0827f89

if (env && env.npm_config_prefix) {
dir = join(env.npm_config_prefix, 'bin');
} else if (env && env.npm_config_local_prefix) {
dir = join(env.npm_config_local_prefix, join('node_modules', '.bin'));
} else {
return callback(new Error('Error finding binary installation directory'));
}

@mheob
Copy link
Author

mheob commented Dec 2, 2022

Yes, I will try it in a couple of days.
I already have an idea how it could work.

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