wasm-pack: Npm package for version 0.10.0 does not work at all on Windows

🐛 Bug description

Version 0.10.0 of the npm package is completely broken on Windows.

Previous versions of wasm-pack worked correctly.

It also works correctly on Linux, this is a Windows-only regression.

This completely breaks the Rollup plugin (on Windows).

🤔 Expected Behavior

It should work correctly.

👟 Steps to reproduce

  1. Create a simple package which uses the wasm-pack npm library:
{
    "dependencies": {
        "wasm-pack": "^0.10.0"
    },
    "scripts": {
        "build": "wasm-pack build"
    }
}
  1. Run yarn install
  2. Run yarn build

You will see the following error:

yarn run v1.22.10
warning package.json: No license field
$ wasm-pack build
You must install wasm-pack before you can run it
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The important line is this:

You must install wasm-pack before you can run it

It seems that version 0.10.0 is not installing wasm-pack automatically (like how it should). Perhaps this is a regression in binary-install?

🌍 Your environment

Include the relevant details of your environment. wasm-pack version: 0.10.0 rustc version: 1.55.0-nightly (32c9b7b09 2021-07-21)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 9
  • Comments: 17 (7 by maintainers)

Most upvoted comments

I just published https://www.npmjs.com/package/wasm-pack/v/0.10.1 that hopefully will work fine on Windows. Please let me know if it does or doesn’t. 🙏

@drager I’d be happy to jump on a Discord call with you and we can pair debug it on my Windows machine if you’re interested.

Thanks for offering! But I managed to get a VM running with Windows 10 on my Linux machine. I did a quick investigation and I could reproduce it. One thing I noticed is that if you run npm install wasm-pack and then looks in node_modules\binary-install you will find a folder called bin with a wasm-pack.exe file in it. If you run it node_modules\binary-install\bin\wasm-pack.exe new my_template and then node_modules\binary-install\bin\wasm-pack.exe build my_template both of those works fine! Not sure why wasm-pack.exe is still left in bin folder in binary-install. If we look in node_modules/.bin there’s no .exe file there, just one without file extension and a wasm-pack.cmd and a wasm-pack.ps1

However, by removing this check https://github.com/EverlastingBugstopper/binary-install/blob/main/packages/binary-install/index.js#L76-L78 in my node_modules it seems to be working…

Meaning the bug seems the be that check only ☝️i.e. buggy binary-install. It does not take file extensions into consideration. this.binaryPath is simply node_modules\binary-install\bin\wasm-pack and not node_modules\binary-install\bin\wasm-pack.exe and wasm-pack does not exists in that folder. wasm-pack.exe does.

This problem has resurfaced in 0.10.3 but downgrading to 0.10.1 works. Windows 11 10.0.22000 Build 22000

@drager Works for me, thanks!

Looking good, for me at least!

C:\Users\Jan\Documents\throwaway  (throwaway@1.0.0)
λ npm init -y
Wrote to C:\Users\Jan\Documents\throwaway\package.json:

{
  "name": "throwaway",
  "version": "1.0.0",
  "main": "index.js",
  "directories": {
    "doc": "docs"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "prisma": "^2.30.2"
  },
  "devDependencies": {},
  "description": ""
}



C:\Users\Jan\Documents\throwaway  (throwaway@1.0.0)
λ npm install wasm-pack

> wasm-pack@0.10.1 postinstall C:\Users\Jan\Documents\throwaway\node_modules\wasm-pack
> node ./install.js

Downloading release from https://github.com/rustwasm/wasm-pack/releases/download/v0.10.1/wasm-pack-v0.10.1-x86_64-pc-windows-msvc.tar.gz
wasm-pack.exe has been installed!
npm WARN throwaway@1.0.0 No description
npm WARN throwaway@1.0.0 No repository field.

+ wasm-pack@0.10.1
added 23 packages from 10 contributors and audited 25 packages in 4.895s

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities


C:\Users\Jan\Documents\throwaway  (throwaway@1.0.0)
λ npx wasm-pack build
Error: crate directory is missing a `Cargo.toml` file; is `.` the wrong directory?

Yes, it downloads the package from the releases page. This is the code which does that.

It does not download the wasm-pack-init.exe, it downloads the .tar.gz (which contains the actual wasm-pack binary).

It correctly installs the node_modules/.bin/wasm-pack and node_modules/.bin/wasm-pack.cmd files.

It also correctly installs the node_modules/wasm-pack/run.js and node_modules/wasm-pack/binary.js files.

All of that works identically to version 0.9.1, so it seems the problem is something in binary-install.

The error is caused by this code in binary-install. That code didn’t exist in version 0.9.1.

I don’t know why that is failing, but that’s as far as my investigation went.