When running the example code, I receive the following error:
{ Error: Cannot find module '/Users/rharrington/src/temp/microjobtest/src/worker.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15) at Function.Module._load (internal/modules/cjs/loader.js:507:25) at Function.Module.runMain (internal/modules/cjs/loader.js:742:12) at MessagePort.port.on (internal/worker.js:445:27) at MessagePort.emit (events.js:182:13) at MessagePort.onmessage (internal/worker.js:66:8) code: 'MODULE_NOT_FOUND' }
Details included below:
OS: OSX v10.13.4
Node: v10.10.0
command: node --experimental-worker index.js
index.js:
(async () => {
const { job } = require('microjob')
try {
// this function will be executed in another thread
const res = await job(() => {
let i = 0
for (i = 0; i < 1000000; i++) {
Array.from({length: 1000}, () => Math.floor(Math.random() * 1000)).sort()
}
return i
})
console.log(res) // 1000000
} catch (err) {
console.error(err)
}
})()
When running the example code, I receive the following error:
{ Error: Cannot find module '/Users/rharrington/src/temp/microjobtest/src/worker.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15) at Function.Module._load (internal/modules/cjs/loader.js:507:25) at Function.Module.runMain (internal/modules/cjs/loader.js:742:12) at MessagePort.port.on (internal/worker.js:445:27) at MessagePort.emit (events.js:182:13) at MessagePort.onmessage (internal/worker.js:66:8) code: 'MODULE_NOT_FOUND' }
Details included below:
OS: OSX v10.13.4
Node: v10.10.0
command: node --experimental-worker index.js
index.js: (async () => { const { job } = require('microjob') try { // this function will be executed in another thread const res = await job(() => { let i = 0 for (i = 0; i < 1000000; i++) { Array.from({length: 1000}, () => Math.floor(Math.random() * 1000)).sort() } return i }) console.log(res) // 1000000 } catch (err) { console.error(err) } })()
package.json : { "name": "microjobtest", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "microjob": "^0.1.0" } }