I am starting to use nodejs 12 and trying to pass from main thread that open workers I need to pass some globals this run with codeceptjs automation, The issue that before I have one main thread and now I want to handle workers also but don't know how the globals will be available on workers. My code for single is
global.host =getHost();
try to use module.exports
example like module.exports.host = getHost();
followed by:
const n = require('./path of file you exported');
n.host;
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.