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

Could not read from file: light\node_modules\node-stdlib-browser\esm\mock\empty.js\promises #16

Closed
thisVioletHydra opened this issue Feb 20, 2023 · 7 comments
Labels

Comments

@thisVioletHydra
Copy link

 VITE v4.1.3  ready in 1590 msLocal:   http://localhost:4000/blitz/admin/lightNetwork: use --host to exposeInspect: http://localhost:4000/blitz/admin/light/blitz/admin/light/__inspect/press h to show help
✘ [ERROR] Could not read from file: D:\WWW\blitz-admin-web-light\node_modules\node-stdlib-browser\esm\mock\empty.js\promises

    node_modules/rollup/dist/es/rollup.js:16:7:
      16import 'node:fs/promises';
         ╵        ~~~~~~~~~~~~~~~~~~

D:\WWW\blitz-admin-web-light\node_modules\esbuild\lib\main.js:1604
  let error = new Error(`${text}${summary}`);
              ^

Error: Build failed with 1 error:
node_modules/rollup/dist/es/rollup.js:16:7: ERROR: Could not read from file: D:\WWW\blitz-admin-web-light\node_modules\node-stdlib-browser\esm\mock\empty.js\promises
    at failureErrorWithLog (D:\WWW\blitz-admin-web-light\node_modules\esbuild\lib\main.js:1604:15)
    at D:\WWW\blitz-admin-web-light\node_modules\esbuild\lib\main.js:1056:28
    at runOnEndCallbacks (D:\WWW\blitz-admin-web-light\node_modules\esbuild\lib\main.js:1476:61)
    at buildResponseToResult (D:\WWW\blitz-admin-web-light\node_modules\esbuild\lib\main.js:1054:7)
    at D:\WWW\blitz-admin-web-light\node_modules\esbuild\lib\main.js:1166:14
    at responseCallbacks.<computed> (D:\WWW\blitz-admin-web-light\node_modules\esbuild\lib\main.js:701:9)
    at handleIncomingPacket (D:\WWW\blitz-admin-web-light\node_modules\esbuild\lib\main.js:756:9)
    at Socket.readFromStdout (D:\WWW\blitz-admin-web-light\node_modules\esbuild\lib\main.js:677:7)
    at Socket.emit (node:events:512:28)
    at addChunk (node:internal/streams/readable:324:12) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: {
        column: 7,
        file: 'node_modules/rollup/dist/es/rollup.js',
        length: 18,
        line: 16,
        lineText: "import 'node:fs/promises';",
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'Could not read from file: D:\\WWW\\blitz-admin-web-light\\node_modules\\node-stdlib-browser\\esm\\mock\\empty.js\\promises'
    }
  ],
  warnings: []
}

Node.js v19.6.0
error Command failed with exit code 1.
@thevalo
Copy link

thevalo commented Feb 28, 2023

I've got the same problem.

@davidmyersdev
Copy link
Owner

Could either of you provide a minimal reproduction using StackBlitz or a similar service?

@davidmyersdev
Copy link
Owner

I think adding support for subpath matching should solve this issue. It's now on my todo list.

@davidmyersdev davidmyersdev added the missing reproduction This issue does not provide a reproducible example of the problem. label Jun 19, 2023
@edpacca
Copy link

edpacca commented Jul 10, 2023

Hi - I encountered a similar issue which I have recreated
Here on stacklitz.

npm run dev or npm run build to see the error.

[vite-plugin-sveltekit-compile] Could not load /home/projects/vitejs-vite-wp5msv/node_modules/node-stdlib-browser/esm/mock/empty.js/promises (imported by node_modules/path-scurry/dist/mjs/index.js): ENOTDIR: not a directory, open '/home/projects/vitejs-vite-wp5msv/node_modules/node-stdlib-browser/esm/mock/empty.js/promises'
✓ built in 3.51s
error during build:
ENOTDIR: not a directory, open '/home/projects/vitejs-vite-wp5msv/node_modules/node-stdlib-browser/esm/mock/empty.js/promises'```

@davidmyersdev davidmyersdev removed the missing reproduction This issue does not provide a reproducible example of the problem. label Aug 22, 2023
@develowper
Copy link

develowper commented Aug 29, 2023

same issue when useing webdriverio, or puppeteer packages (web driver automation libraries)

just import them
import {remote} from 'webdriverio'

and these are places that vite stuck:

node_modules/webdriverio/build/utils/index.js:1:15:
1 │ import fs from 'node:fs/promises';

node_modules/fetch-blob/streams.cjs:14:40:
14 │ Object.assign(globalThis, require('node:stream/web'))

@davidmyersdev
Copy link
Owner

After looking into this more, I think the best solution is to either use the new overrides feature (which would allow you to use your own polyfill for fs) or to externalize the dependency using something like vite-plugin-externalize-deps.

@UndarkAido
Copy link

I'm trying to add @xmcl/resourcepack to a Vite Three.js project and I'm utterly failing. You say to use overrides or to externalize the dependency but how would I actually do that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

6 participants