stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.74k stars 140 forks source link

Module not found: Can't resolve 'fs' #1105

Closed fix closed 3 months ago

fix commented 1 year ago

Describe the bug

When using some dependencies (here it seems using cosmiconfig), the error stack is

Import trace for requested module:
./node_modules/@lingui/conf/node_modules/cosmiconfig/dist/Explorer.js
./node_modules/@lingui/conf/node_modules/cosmiconfig/dist/index.js
./node_modules/@lingui/conf/dist/index.mjs
./node_modules/@lingui/macro/dist/index.mjs
./src/pages/index.tsx
wait  - compiling /_error (client and server)...
error - ./node_modules/@lingui/conf/node_modules/cosmiconfig/dist/readFile.js:9:0
Module not found: Can't resolve 'fs'

Link to the blitz that caused the error

https://pr.new/github.com/lingui/js-lingui/tree/main/examples/nextjs-swc

Steps to reproduce

Go to the blitz and see the error.

Expected behavior

Should compile properly. My understanding is that webcontainer is providing a polyfill for fs module.

Parity with Local

Screenshots

No response

Platform

Version = 1.72.0
Hash = 93111c64aac6cfd1cd0481904cb37c21693aa7f3
WebContainer = 77657b1e

Browser name  = Chrome
Full version  = 114.0.0.0
Major version = 114
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
performance.memory = {
  "totalJSHeapSize": 105696596,
  "usedJSHeapSize": 98368132,
  "jsHeapSizeLimit": 4294705152
}

Additional context

No response

jrvidal commented 1 year ago

@fix Thanks for the report.

There is an issue which might or might not be the root cause: we don't support yarn v2 or v3 (see our docs). We auto-detect yarn.lock and proceed with a yarn v1 installation, but that is far from guaranteeing a similar setup to your local machine.

fix commented 1 year ago

@jrvidal thanks for your answer. I have a private repo with the exact same issue, but i use pnpm instead of yarn

jrvidal commented 1 year ago

Could you share it?