I'm investigating a larger issue where I am trying to import a webpacked javascript file into a NextJS project that uses Worker
and keep getting ReferenceError: Worker is not defined
. I've minimized it to the following:
npx create-next-app@latest
module.exports = Worker;
pages/_app.js
and try to import the file we just created in the previous step const shouldThrow = require('../myFile.js')
.npm run build
, should now throw ReferenceError: Worker is not defined
Why does this happen and how can I fix it?
If you check docs
const { Worker } = require("node:worker_threads");
console.log("W", Worker);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.