wxt-dev / wxt

⚡ Next-gen Web Extension Framework
https://wxt.dev
MIT License
4.19k stars 173 forks source link

"module wxt not found" in GitHub Actions during yarn install #1058

Open mklueh opened 16 hours ago

mklueh commented 16 hours ago

Describe the bug

So my overall setup is Nx, Yarn Berry 4.5.0 and GitHub Actions for CI.

I've installed wxt and @wxt-dev/vue locally, as dev dependencies and on my PC everything works as expected.

In the CI however the yarn install command fails with

➤ YN0007: │ sharp@npm:0.33.5 must be built because it never has been before or the last one failed
  ➤ YN0007: │ @swc/core@npm:1.7.26 [da0cf] must be built because it never has been before or the last one failed
  ➤ YN0007: │ sharp@npm:0.32.6 must be built because it never has been before or the last one failed
  ➤ YN0007: │ better-sqlite3@npm:11.3.0 must be built because it never has been before or the last one failed
  ➤ YN0000: │ @my-workspace/extension@workspace:apps/browser-extension STDERR command not found: wxt
  ➤ YN0009: │ @my-workspace/extension@workspace:apps/browser-extension couldn't be built successfully (exit code 127, logs can be found here: /tmp/xfs-74[90](https://github.com/my-organization/my-workspace/actions/runs/11242673931/job/31277891170#step:13:94)8f99/build.log)

My first idea was to expose the contents of node_modules/.bin as ENV variables with

      - name: Set ENV variables to node binaries
        run: export PATH="$(yarn bin):$PATH"

But this doesn't make sense, as it fails during the install command and this would only run afterwards. I guess it's mainly the prepare command that is called during install and immediately fails.

I've tried to install wxt globally as a backup solution, leading to another error

  [fail] Command failed after 13.4 s
  Error:  Cannot find package '@wxt-dev/module-vue' imported from /opt/hostedtoolcache/node/22.9.0/x64/lib/node_modules/wxt/dist/core/resolve-config.mjs
    at packageResolve (node:internal/modules/esm/resolve:839:9)
    at moduleResolve (node:internal/modules/esm/resolve:908:18)
    at defaultResolve (node:internal/modules/esm/resolve:1038:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
    at onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:482:36)
    at TracingChannel.tracePromise (node:diagnostics_channel:337:14)
    at ModuleLoader.import (node:internal/modules/esm/loader:481:21)
    at defaultImportModuleDynamicallyForModule (node:internal/modules/esm/utils:214:31)
    at importModuleDynamicallyCallback (node:internal/modules/esm/utils:253:12)
    at /opt/hostedtoolcache/node/22.9.0/x64/lib/node_modules/wxt/dist/core/resolve-config.mjs:324:19
    at Array.map (<anonymous>)
    at resolveWxtUserModules (/opt/hostedtoolcache/node/22.9.0/x64/lib/node_modules/wxt/dist/core/resolve-config.mjs:323:13)
    at resolveConfig (/opt/hostedtoolcache/node/22.9.0/x64/lib/node_modules/wxt/dist/core/resolve-config.mjs:88:29)
    at async registerWxt (/opt/hostedtoolcache/node/22.9.0/x64/lib/node_modules/wxt/dist/core/wxt.mjs:10:18)
    at async prepare (/opt/hostedtoolcache/node/22.9.0/x64/lib/node_modules/wxt/dist/core/prepare.mjs:5:3)
    at async /opt/hostedtoolcache/node/22.9.0/x64/lib/node_modules/wxt/dist/cli/commands.mjs:76:5
    at async CAC.<anonymous> (/opt/hostedtoolcache/node/22.9.0/x64/lib/node_modules/wxt/dist/cli/cli-utils.mjs:16:22)
    at async /opt/hostedtoolcache/node/22.9.0/x64/lib/node_modules/wxt/dist/cli/index.mjs:11:1

Not sure if this is related to Yarn, but I'd appreciate any help.

Reproduction

Not easily reproducible

Steps to reproduce

No response

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
    Memory: 1.73 GB / 15.77 GB
  Binaries:
    Node: 22.9.0 - ~\.nvm\versions\node\v22.9.0\bin\node.EXE
    Yarn: 4.5.0 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.19.4 - ~\Workspace\my-workspace\node_modules\.bin\npm.CMD
  npmPackages:
    vite: 5.4.8 => 5.4.8
    wxt: ^0.19.11 => 0.19.11

Used Package Manager

yarn

Validations

aklinker1 commented 11 hours ago

Hmm, yeah, looks like yarn 4.5 just doesn't work with the latest version.

repro.zip

yarn

With @wxt-dev/module-vue:

$ cat /private/var/folders/g2/ztr_kd996gv4vv11lxwggz8c0000gn/T/xfs-6cd13a85/build.log
# This file contains the result of Yarn building a package (wxt-starter@workspace:.)
# Script name: postinstall

WXT 0.19.11
ℹ Generating types...
file:///Users/aklinker1/.yarn/berry/cache/mlly-npm-1.7.2-dbf2e47745-10c0.zip/node_modules/mlly/dist/index.mjs:2102
    const error = new Error(
                  ^

Error: Cannot find module wxt/client imported from file:///Users/aklinker1/Development/local/wxt-issue-1058, file:///Users/aklinker1/Development/local/, file:///Users/aklinker1/Development/local/wxt-issue-1058/_index.js, file:///Users/aklinker1/Development/local/node_modules
    at _resolve (file:///Users/aklinker1/.yarn/berry/cache/mlly-npm-1.7.2-dbf2e47745-10c0.zip/node_modules/mlly/dist/index.mjs:2102:19)
    at resolveSync (file:///Users/aklinker1/.yarn/berry/cache/mlly-npm-1.7.2-dbf2e47745-10c0.zip/node_modules/mlly/dist/index.mjs:2111:10)
    at resolvePathSync (file:///Users/aklinker1/.yarn/berry/cache/mlly-npm-1.7.2-dbf2e47745-10c0.zip/node_modules/mlly/dist/index.mjs:2121:24)
    at resolvePath (file:///Users/aklinker1/.yarn/berry/cache/mlly-npm-1.7.2-dbf2e47745-10c0.zip/node_modules/mlly/dist/index.mjs:2125:28)
    at resolvePackageJSON (file:///Users/aklinker1/.yarn/berry/cache/pkg-types-npm-1.2.1-fd28245c53-10c0.zip/node_modules/pkg-types/dist/index.mjs:103:52)
    at extractExports (file:///Users/aklinker1/.yarn/berry/cache/unimport-npm-3.13.1-0226725ef1-10c0.zip/node_modules/unimport/dist/shared/unimport.1c7b6182.mjs:289:33)
    at resolvePackagePreset (file:///Users/aklinker1/.yarn/berry/cache/unimport-npm-3.13.1-0226725ef1-10c0.zip/node_modules/unimport/dist/shared/unimport.1c7b6182.mjs:271:25)
    at resolvePreset (file:///Users/aklinker1/.yarn/berry/cache/unimport-npm-3.13.1-0226725ef1-10c0.zip/node_modules/unimport/dist/shared/unimport.1c7b6182.mjs:1196:18)
    at file:///Users/aklinker1/.yarn/berry/cache/unimport-npm-3.13.1-0226725ef1-10c0.zip/node_modules/unimport/dist/shared/unimport.1c7b6182.mjs:1220:18
    at Array.map (<anonymous>)
    at resolveBuiltinPresets (file:///Users/aklinker1/.yarn/berry/cache/unimport-npm-3.13.1-0226725ef1-10c0.zip/node_modules/unimport/dist/shared/unimport.1c7b6182.mjs:1216:46)
    at createInternalContext (file:///Users/aklinker1/.yarn/berry/cache/unimport-npm-3.13.1-0226725ef1-10c0.zip/node_modules/unimport/dist/shared/unimport.1c7b6182.mjs:1340:20)
    at createUnimport (file:///Users/aklinker1/.yarn/berry/cache/unimport-npm-3.13.1-0226725ef1-10c0.zip/node_modules/unimport/dist/shared/unimport.1c7b6182.mjs:1226:15)
    at file:///Users/aklinker1/Development/local/wxt-issue-1058/.yarn/__virtual__/wxt-virtual-1da7d21582/4/.yarn/berry/cache/wxt-npm-0.19.11-89f86a5551-10c0.zip/node_modules/wxt/dist/builtin-modules/unimport.mjs:21:20
    at callEachWith (file:///Users/aklinker1/.yarn/berry/cache/hookable-npm-5.5.3-82b0342097-10c0.zip/node_modules/hookable/dist/index.mjs:68:5)
    at file:///Users/aklinker1/.yarn/berry/cache/hookable-npm-5.5.3-82b0342097-10c0.zip/node_modules/hookable/dist/index.mjs:205:11
    at <anonymous>
    at async registerWxt (file:///Users/aklinker1/Development/local/wxt-issue-1058/.yarn/__virtual__/wxt-virtual-1da7d21582/4/.yarn/berry/cache/wxt-npm-0.19.11-89f86a5551-10c0.zip/node_modules/wxt/dist/core/wxt.mjs:39:3)
    at async prepare (file:///Users/aklinker1/Development/local/wxt-issue-1058/.yarn/__virtual__/wxt-virtual-1da7d21582/4/.yarn/berry/cache/wxt-npm-0.19.11-89f86a5551-10c0.zip/node_modules/wxt/dist/core/prepare.mjs:5:3)
    at async file:///Users/aklinker1/Development/local/wxt-issue-1058/.yarn/__virtual__/wxt-virtual-1da7d21582/4/.yarn/berry/cache/wxt-npm-0.19.11-89f86a5551-10c0.zip/node_modules/wxt/dist/cli/commands.mjs:76:5
    at async CAC.<anonymous> (file:///Users/aklinker1/Development/local/wxt-issue-1058/.yarn/__virtual__/wxt-virtual-1da7d21582/4/.yarn/berry/cache/wxt-npm-0.19.11-89f86a5551-10c0.zip/node_modules/wxt/dist/cli/cli-utils.mjs:16:22)
    at async file:///Users/aklinker1/Development/local/wxt-issue-1058/.yarn/__virtual__/wxt-virtual-1da7d21582/4/.yarn/berry/cache/wxt-npm-0.19.11-89f86a5551-10c0.zip/node_modules/wxt/dist/cli/index.mjs:11:1 {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.20.3

Without it:

$ cat /private/var/folders/g2/ztr_kd996gv4vv11lxwggz8c0000gn/T/xfs-87e7677c/build.log
# This file contains the result of Yarn building a package (wxt-starter@workspace:.)
# Script name: postinstall

WXT 0.19.11
ℹ Generating types...
file:///Users/aklinker1/.yarn/berry/cache/mlly-npm-1.7.2-dbf2e47745-10c0.zip/node_modules/mlly/dist/index.mjs:2102
    const error = new Error(
                  ^

Error: Cannot find module wxt/client imported from file:///Users/aklinker1/Development/local/wxt-issue-1058, file:///Users/aklinker1/Development/local/, file:///Users/aklinker1/Development/local/wxt-issue-1058/_index.js, file:///Users/aklinker1/Development/local/node_modules
    at _resolve (file:///Users/aklinker1/.yarn/berry/cache/mlly-npm-1.7.2-dbf2e47745-10c0.zip/node_modules/mlly/dist/index.mjs:2102:19)
    at resolveSync (file:///Users/aklinker1/.yarn/berry/cache/mlly-npm-1.7.2-dbf2e47745-10c0.zip/node_modules/mlly/dist/index.mjs:2111:10)
    at resolvePathSync (file:///Users/aklinker1/.yarn/berry/cache/mlly-npm-1.7.2-dbf2e47745-10c0.zip/node_modules/mlly/dist/index.mjs:2121:24)
    at resolvePath (file:///Users/aklinker1/.yarn/berry/cache/mlly-npm-1.7.2-dbf2e47745-10c0.zip/node_modules/mlly/dist/index.mjs:2125:28)
    at resolvePackageJSON (file:///Users/aklinker1/.yarn/berry/cache/pkg-types-npm-1.2.1-fd28245c53-10c0.zip/node_modules/pkg-types/dist/index.mjs:103:52)
    at extractExports (file:///Users/aklinker1/.yarn/berry/cache/unimport-npm-3.13.1-0226725ef1-10c0.zip/node_modules/unimport/dist/shared/unimport.1c7b6182.mjs:289:33)
    at resolvePackagePreset (file:///Users/aklinker1/.yarn/berry/cache/unimport-npm-3.13.1-0226725ef1-10c0.zip/node_modules/unimport/dist/shared/unimport.1c7b6182.mjs:271:25)
    at resolvePreset (file:///Users/aklinker1/.yarn/berry/cache/unimport-npm-3.13.1-0226725ef1-10c0.zip/node_modules/unimport/dist/shared/unimport.1c7b6182.mjs:1196:18)
    at file:///Users/aklinker1/.yarn/berry/cache/unimport-npm-3.13.1-0226725ef1-10c0.zip/node_modules/unimport/dist/shared/unimport.1c7b6182.mjs:1220:18
    at Array.map (<anonymous>)
    at resolveBuiltinPresets (file:///Users/aklinker1/.yarn/berry/cache/unimport-npm-3.13.1-0226725ef1-10c0.zip/node_modules/unimport/dist/shared/unimport.1c7b6182.mjs:1216:46)
    at createInternalContext (file:///Users/aklinker1/.yarn/berry/cache/unimport-npm-3.13.1-0226725ef1-10c0.zip/node_modules/unimport/dist/shared/unimport.1c7b6182.mjs:1340:20)
    at createUnimport (file:///Users/aklinker1/.yarn/berry/cache/unimport-npm-3.13.1-0226725ef1-10c0.zip/node_modules/unimport/dist/shared/unimport.1c7b6182.mjs:1226:15)
    at file:///Users/aklinker1/Development/local/wxt-issue-1058/.yarn/__virtual__/wxt-virtual-1da7d21582/4/.yarn/berry/cache/wxt-npm-0.19.11-89f86a5551-10c0.zip/node_modules/wxt/dist/builtin-modules/unimport.mjs:21:20
    at callEachWith (file:///Users/aklinker1/.yarn/berry/cache/hookable-npm-5.5.3-82b0342097-10c0.zip/node_modules/hookable/dist/index.mjs:68:5)
    at file:///Users/aklinker1/.yarn/berry/cache/hookable-npm-5.5.3-82b0342097-10c0.zip/node_modules/hookable/dist/index.mjs:205:11
    at <anonymous>
    at async registerWxt (file:///Users/aklinker1/Development/local/wxt-issue-1058/.yarn/__virtual__/wxt-virtual-1da7d21582/4/.yarn/berry/cache/wxt-npm-0.19.11-89f86a5551-10c0.zip/node_modules/wxt/dist/core/wxt.mjs:39:3)
    at async prepare (file:///Users/aklinker1/Development/local/wxt-issue-1058/.yarn/__virtual__/wxt-virtual-1da7d21582/4/.yarn/berry/cache/wxt-npm-0.19.11-89f86a5551-10c0.zip/node_modules/wxt/dist/core/prepare.mjs:5:3)
    at async file:///Users/aklinker1/Development/local/wxt-issue-1058/.yarn/__virtual__/wxt-virtual-1da7d21582/4/.yarn/berry/cache/wxt-npm-0.19.11-89f86a5551-10c0.zip/node_modules/wxt/dist/cli/commands.mjs:76:5
    at async CAC.<anonymous> (file:///Users/aklinker1/Development/local/wxt-issue-1058/.yarn/__virtual__/wxt-virtual-1da7d21582/4/.yarn/berry/cache/wxt-npm-0.19.11-89f86a5551-10c0.zip/node_modules/wxt/dist/cli/cli-utils.mjs:16:22)
    at async file:///Users/aklinker1/Development/local/wxt-issue-1058/.yarn/__virtual__/wxt-virtual-1da7d21582/4/.yarn/berry/cache/wxt-npm-0.19.11-89f86a5551-10c0.zip/node_modules/wxt/dist/cli/index.mjs:11:1 {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.20.3

Didn't get your exact error, but things obviously don't work.

I don't know enough about yarn berry, but you could try using it in pnpm mode as a workaround?

mklueh commented 5 hours ago

Hello,

I've tried pnpm as well as pnp modes.

pnpm fails with an obsucre linking issue regarding the shiki package while the pnp issue now shifts the problem to the nuxt package

https://github.com/nuxt/cli/issues/217#issuecomment-2084624223