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

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

Open
SpiZeak opened this issue Oct 4, 2023 · 11 comments
Open

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

SpiZeak opened this issue Oct 4, 2023 · 11 comments
Labels
bug Something isn't working node.js Compatibility with Node.js APIs

Comments

@SpiZeak
Copy link

SpiZeak commented Oct 4, 2023

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.

@SpiZeak SpiZeak added the bug Something isn't working label Oct 4, 2023
@Natetronn
Copy link

Natetronn commented Oct 7, 2023

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)

@Electroid Electroid added the node.js Compatibility with Node.js APIs label Oct 9, 2023
@patrickelectric
Copy link

Same problem here!

patrickelectric added a commit to patrickelectric/BlueOS-docker that referenced this issue Oct 13, 2023
Fix problems with vite
Check oven-sh/bun#6302

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
@Natetronn
Copy link

Natetronn commented Oct 13, 2023

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
Copy link

Doesn't work for me on Bun 1.0.7

@CommanderGL
Copy link

Still not working on Bun version 1.0.9

@realflavioc
Copy link

Same on Bun version 1.0.11

@rotu
Copy link

rotu commented Nov 9, 2023

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"
}

rotu added a commit to rotu/workbox that referenced this issue Nov 9, 2023
Fixes a build error seen here: oven-sh/bun#6302
@Natetronn
Copy link

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
Copy link

rotu commented Nov 9, 2023

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

@Natetronn
Copy link

Natetronn commented Nov 9, 2023

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
Copy link

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

tropicadri pushed a commit to GoogleChrome/workbox that referenced this issue Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node.js Compatibility with Node.js APIs
Projects
None yet
Development

No branches or pull requests

9 participants