Closed kwshi closed 1 month ago
I don't know enough about how node package resolution works to troubleshoot why/how exactly this is happening. Here are only some clues-- the binaryExists
function tries to first run require.resolve('y-sweet')
in order to find the binary path; my hunch is that this is the step that is failing, even though it shouldn't. I don't know why though; the node_modules/y-sweet
and node_modules/y-sweet/node_modules/y-sweet
paths are both there-- maybe there needs to be a package.json
? a main
entry in the package.json
? etc.
Thanks for reporting this, @kwshi . #277 should fix it once merged.
I have a relatively slow internet connection and noticed that even after the initial download/install (
pnpm add -D y-sweet@latest
) it always took 30+ seconds forpnpm exec y-sweet
to launch. Some light digging leads me to think that the binary is getting re-downloaded every time the CLI is invoked, which doesn't seem like the correct/intended behavior.Here's my train of thought:
js-pkg/server/package.json
specifies the entry point topnpm exec y-sweet
asjs-pkg/server/src/run.js
, whose contents are: https://github.com/jamsocket/y-sweet/blob/35ea7d34693ea9a4fd194247945b330c70ba35be/js-pkg/server/src/run.js#L6-L14I added some
console.log
s to try to inspect what was happening behind the scenes:pnpm exec y-sweet
displaysBINARY FAILED Error: Cannot find module 'y-sweet'
, then (after several minutes on my slow internet)INSTALLED BINARY /tmp/test/node_modules/.pnpm/y-sweet@0.2.2/node_modules/y-sweet/node_modules/y-sweet/bin/y-sweet-0.2.2
. I tried to invoke the binary manually; weirdly enough I had to manuallychmod +x
it first, but then it worked fine. (This happened during my attempts to reproduce the error from a blank project; I don't recall having to do this originally when the error first came up. I don't know what this is about, but it seems like a separate issue.)pnpm exec y-sweet
displays the exact same error message instead ofBINARY EXISTS
etc. and makes me wait several minutes while it redownloads the binary.In case this information is relevant: