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

Error: No such module "node:os". #7655

Open
hotrush opened this issue Dec 17, 2024 · 3 comments
Open

Error: No such module "node:os". #7655

hotrush opened this issue Dec 17, 2024 · 3 comments
Labels
awaiting reporter response Needs clarification or followup from OP

Comments

@hotrush
Copy link

hotrush commented Dec 17, 2024

I'm trying to test my worker with miniflare and so adding next code to my index.spec.ts

import { Miniflare } from 'miniflare';

const mf = new Miniflare({
	modules: true,
	scriptPath: './src/index.ts',
	r2Buckets: ['R2_BUCKET'],
});

When running it i'm getting an error:

Using vars defined in .dev.vars
[vpw:inf] Starting isolated runtimes for vitest.config.mts...
[mf:wrn] The latest compatibility date supported by the installed Cloudflare Workers Runtime is "2024-12-05",
but you've requested "2024-12-16". Falling back to "2024-12-05"...
workerd/server/server.c++:3052: error: Fallback service failed to fetch module; payload = ; spec = /?specifier=node%3Aos&referrer=%2FUsers%2Frush%2FProjects%2Fproj%2Fnode_modules%2Fminiflare%2Fdist%2Fsrc%2Findex.js%3Fmf_vitest_no_cjs_esm_shim&rawSpecifier=node%3Aos
 ❯ test/index.spec.ts (0)

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  test/index.spec.ts [ test/index.spec.ts ]
Error: No such module "node:os".
 ❯ Users/rush/Projects/proj/node_modules/miniflare/dist/src/index.js?mf_vitest_no_cjs_esm_shim:2623:26

Node: v20.17.0
Miniflare: 3.20241205.0

@andyjessop
Copy link
Contributor

@hotrush thanks very much for reporting this! Would you be able to provide us with a minimal reproduction? I can't reproduce this locally, and I'm wondering how this node:os dependency is creeping into the code.

@andyjessop andyjessop added the needs reproduction Needs reproduction from OP label Dec 17, 2024
@hotrush
Copy link
Author

hotrush commented Dec 17, 2024

@andyjessop here it is https://github.com/hotrush/cf-miniflare-eror, just run npm run test.

@emily-shen emily-shen removed the needs reproduction Needs reproduction from OP label Jan 2, 2025
@emily-shen
Copy link
Contributor

hiya, it looks like you're using the vitest integration as well as creating a miniflare instance yourself? Unless I'm missing something about your setup, you should be able to do this with just vitest (see this on how to use env to perform actions on a resource) which should not have this issue.

@emily-shen emily-shen transferred this issue from cloudflare/miniflare Jan 2, 2025
@emily-shen emily-shen added the awaiting reporter response Needs clarification or followup from OP label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reporter response Needs clarification or followup from OP
Projects
Status: Untriaged
Development

No branches or pull requests

3 participants