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 because web-worker isn't shipped as esm module #6

Closed
TimDaub opened this issue Sep 21, 2024 · 1 comment · Fixed by #7
Closed

error because web-worker isn't shipped as esm module #6

TimDaub opened this issue Sep 21, 2024 · 1 comment · Fixed by #7

Comments

@TimDaub
Copy link
Contributor

TimDaub commented Sep 21, 2024

I import make-asynchronous on node 18.20. I import it in a .mjs file:

import makeAsync from "make-asynchronous";

but it immediately throws

[1] (node:6967) Warning: To load an ES module, set "type": "module" in the package.json or use
 the .mjs extension.
[1] (Use `node --trace-warnings ...` to show where the warning was created)                   [1] /Users/timdaub/Projects/attestate/kiwistand/node_modules/web-worker/node.js:17            [1] import URL from 'url';
[1] ^^^^^^
[1]
[1] SyntaxError: Cannot use import statement outside a module                                 [1]     at internalCompileFunction (node:internal/vm:76:18)
[1]     at wrapSafe (node:internal/modules/cjs/loader:1283:20)
[1]     at Module._compile (node:internal/modules/cjs/loader:1328:27)
[1]     at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
[1]     at Module.load (node:internal/modules/cjs/loader:1203:32)
[1]     at Module._load (node:internal/modules/cjs/loader:1019:12)
[1]     at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:203:29)
[1]     at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
[1]     at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)
[1]     at async loadESM (node:internal/process/esm_loader:34:7)
[1]     at async handleMainPromise (node:internal/modules/run_main:106:12)
[1]                                                                                           [1] Node.js v18.20.0
[1] npm run start exited with code 1

So I try to set type: module in my package.json but it isn't solving it.
However, when I go into node_modules/web-worker/package.json, and set it there, the problem is fixed.

Wasn't sure where to create the issue, maybe it's a web-worker issue

related issues at web-worker:

users of make-asynchronous can work-around this issue by defining in their dependencies

"web-worker": ">=1.2.0 <1.3.0"
TimDaub added a commit to TimDaub/make-asynchronous that referenced this issue Sep 21, 2024
@sindresorhus
Copy link
Owner

// @developit

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

Successfully merging a pull request may close this issue.

2 participants