bytecodealliance / jco

JavaScript toolchain for working with WebAssembly Components
https://bytecodealliance.github.io/jco/
Apache License 2.0
640 stars 63 forks source link

Unable to locate the @bytecodealliance/preview2-shim package #482

Closed peter-jerry-ye closed 3 months ago

peter-jerry-ye commented 3 months ago

Hi,

I have both @bytecodealliance/preview2-shim and @bytecodealliance/jco installed with npm install.

{
    "dependencies": {
        "@bytecodealliance/jco": "^1.4.0",
        "@bytecodealliance/preview2-shim": "^0.16.4"
    }
}

When I run npx jco serve xxx.wasm, I got the following error:

(jco serve) Error: Unable to locate the @bytecodealliance/preview2-shim package, make sure it is installed.

It seems that the import.meta.url here: https://github.com/bytecodealliance/jco/blob/3946278b4471961f2d3a6b80576097996472bc07/src/cmd/run.js#L88 gives me the path to the node_modules/@bytecodealliance/jco/src/cmd/run.js

Versions:

rajsite commented 3 months ago

Seeing similar behavior node 20, same packages, Windows (in-case it's OS-specific).

guybedford commented 3 months ago

This could be due to the npm deduping logic moving the install URL to ../../../node_modules/@bytecodealliance/preview2-shim effectively.

We should update this codepath to do a node_modules backtracking search for the folder name in this way at this point in the code.

Alternatively a local install of Jco may fix this.

PRs very very welcome.