wilk / microjob

A tiny wrapper for turning Node.js worker threads into easy-to-use routines for heavy CPU loads.
https://wilk.github.io/microjob/
MIT License
2.02k stars 47 forks source link

crashing on require in node10 #26

Closed mkg20001 closed 6 years ago

mkg20001 commented 6 years ago
$ node
> require('microjob')
Error: Cannot find module 'worker_threads'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
$ node -v
v10.11.0
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.5 LTS
Release:    16.04
Codename:   xenial
addaleax commented 6 years ago

From the README:

Microjob can be used only with Node.js 10.5+ and with the --experimental-worker flag activated, otherwise it won't work.

Using node --experimental-worker should make this work.

Workers are currently still experimental in Node.js, and require this flag, since it is possible that there will be changes to the API without a semver-major release; see https://github.com/nodejs/node/issues/22940 for the progress on that.

mkg20001 commented 6 years ago

Oops, seems like coding at 10pm isn't the best idea ;)