vite-plugin-pwa
vite-plugin-pwa copied to clipboard
Build Failed at yarn berry with pnp mode.
Hi. I have a problem with build in Yarn berry with pnp environment. Here's my Build Environment.
MacOS 12.4(M1 Max, also failed in Intel Mac) Yarn 3.2.1(berry, pnp mode enabled) NodeJS 16.13.2 Vite 2.9.9 vite-plugin-pwa 0.12.0 typescript 4.7.2
Here's my console error with pnp environment.

By the way, I can successfully build at yarn classic(1.23.x) and yarn berry with node-modules linker.
-
yarn berry with node-modules linker.

-
yarn classic

@CXZ7720 try adding workbox-window as dev dependency
@userquin sorry for confusing, I updated attached image.

@CXZ7720 can you disable the vite compress plugin to check if the problem is using also that plugin?
@userquin It fails same again.

@CXZ7720 can you provide the vite config file?
@userquin Here's my vite.config.ts
/* eslint-disable camelcase */
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
VitePWA(),
],
publicDir: './public',
})
@CXZ7720 weird, try logging the error on write-sw-using-default-template.js, it seems to be shadowed by workbox-build (no stacktrace with the cause, maybe you need to add some extra dependency), add a console.error('weird', error) before line 68
throw new Error(`${errors_1.errors['sw-write-failure']} '${err.message}'`);
@userquin I'm affraid if it is stupid question, How can I edit the line of zipped file on ide?
upps, sorry, I don't check that module is inside a zip... (maybe it is just a name, it is a zip file on your file system?)
Maybe you can debug it, just add a breakpoint on line 68 and check the error
@userquin Yes It is zip file. I can't edit the file.

Hi @CXZ7720 , I had the same problem and I just solved it by updating nodejs to the latest LTS available, 16.15.1.
My current configuration is:
Yarn 3.2.1(berry, pnp mode enabled)
NodeJS 16.15.1
Vite 2.9.12
vite-plugin-pwa 0.12.0
typescript 4.7.4
Hope it can help you too!