oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.96k stars 2.75k forks source link

"Unable to write the service worker file" with vite-plugin-pwa #6302

Open SpiZeak opened 1 year ago

SpiZeak commented 1 year ago

What version of Bun is running?

1.0.4+745b6b94ee56cad24d475799690cc9a89957d15b

What platform is your computer?

Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

  1. Install/upgrade Bun to version 1.0.4
  2. Run bun run --bun vite build with vite-plugin-pwa in vite.config.js
  3. The error will be: Unable to write the service worker file. ''

What is the expected behavior?

The build runs without errors

What do you see instead?

error during build:
Error: Unable to write the service worker file. ''
    at <anonymous> (/home/user/project/node_modules/workbox-build/build/lib/write-sw-using-default-template.js:67:81)
    at processTicksAndRejections (:55:77)
error: "vite" exited with code 1 (SIGHUP

Additional information

Running the same command with version 1.0.3 works flawlessly.

Natetronn commented 1 year ago

I just ran into this as well, although I'm using the Astro version: @vite-pwa/astro. I get the following error:

 error   Unable to write the service worker file. ''
  File:
    /myproj/node_modules/workbox-build/build/lib/write-sw-using-default-template.js:67:81
  Code:
    66 |             throw new Error(errors_1.errors['sw-write-failure-directory']);
    > 67 |         }
         |                                                                                 ^
      68 |         throw new Error(`${errors_1.errors['sw-write-failure']} '${err.message}'`);
      69 |     }
      70 | }
  Stacktrace:
Error: Unable to write the service worker file. ''
    at <anonymous> (/myproj/node_modules/workbox-build/build/lib/write-sw-using-default-template.js:67:81)
    at processTicksAndRejections (:55:77)
patrickelectric commented 1 year ago

Same problem here!

Natetronn commented 1 year ago

I downgraded from bun 1.0.4 to 1.0.3 for the time being. I see bun is currently at 1.0.6. I may try that and report back, in the off chance this was fixed.

real-jame commented 1 year ago

Doesn't work for me on Bun 1.0.7

CrossScarDev commented 11 months ago

Still not working on Bun version 1.0.9

flaviouk commented 11 months ago

Same on Bun version 1.0.11

rotu commented 11 months ago

I think it's this bug https://github.com/rollup/plugins/pull/835 which is re-exposed by https://github.com/googlechrome/workbox.

Workaround is to override the dependency in package.json:

"overrides": {
  "@rollup/plugin-node-resolve": "^15.2.3"
}
Natetronn commented 11 months ago

I think it's this bug rollup/plugins#835 which is re-exposed by https://github.com/googlechrome/workbox.

Workaround is to override the dependency in package.json:

"overrides": {
  "@rollup/plugin-node-resolve": "^15.2.3"
}

Does that go in our main package.json or in the vite-pwa?

rotu commented 11 months ago

@Natetronn you can put it in your project's package.json but I'll submit a PR for vite-plugin-pwa as well!

Natetronn commented 11 months ago

Same error on 1.0.11, although let me delete the lock and node_modules folder and install fresh an report back.

Update:

I deleted bun.lockb and node_modules folder and ran bun install again and it worked. Thanks @rotu!

ElectricS01 commented 10 months ago

I think it's this bug rollup/plugins#835 which is re-exposed by https://github.com/googlechrome/workbox.

Workaround is to override the dependency in package.json:

"overrides": {
  "@rollup/plugin-node-resolve": "^15.2.3"
}

Fixed it for me thanks