vite-plugin-pwa icon indicating copy to clipboard operation
vite-plugin-pwa copied to clipboard

Build Failed at yarn berry with pnp mode.

Open CXZ7720 opened this issue 3 years ago • 11 comments
trafficstars

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. image

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. image

  • yarn classic image

CXZ7720 avatar Jun 01 '22 08:06 CXZ7720

@CXZ7720 try adding workbox-window as dev dependency

userquin avatar Jun 01 '22 09:06 userquin

@userquin sorry for confusing, I updated attached image. image

CXZ7720 avatar Jun 01 '22 09:06 CXZ7720

@CXZ7720 can you disable the vite compress plugin to check if the problem is using also that plugin?

userquin avatar Jun 01 '22 10:06 userquin

@userquin It fails same again.

image

CXZ7720 avatar Jun 01 '22 10:06 CXZ7720

@CXZ7720 can you provide the vite config file?

userquin avatar Jun 01 '22 10:06 userquin

@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 avatar Jun 01 '22 10:06 CXZ7720

@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 avatar Jun 01 '22 10:06 userquin

@userquin I'm affraid if it is stupid question, How can I edit the line of zipped file on ide?

CXZ7720 avatar Jun 01 '22 10:06 CXZ7720

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 avatar Jun 01 '22 11:06 userquin

@userquin Yes It is zip file. I can't edit the file. image

CXZ7720 avatar Jun 01 '22 11:06 CXZ7720

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!

danykina avatar Jun 23 '22 21:06 danykina