Open pito-svk opened 8 years ago
I am also facing same issue
index.js
require('babel-core/register')({
presets: ['node6']
});
const app = require('./test.js');
app();``
test.js
import cluster from 'cluster'
module.exports = function() {
if (cluster.isMaster) {
for(let i = 0; i < 2; ++i) {
cluster.fork();
}
cluster.on('exit', (worker) => console.log('Worker ' + worker.process.pid + ' exitted.'));
} else {
console.log('Worker ' + cluster.worker.process.pid);
process.exit(0);
}
}
Run : sudo babel-node --presets node6 index.js
I got an error, when I use import instead of require.
When I use:
const cluster = require('cluster');
everything works,
but when I use
import * as cluster from 'cluster';
I got
I run cluster with this code:
`if (cluster.isMaster) { var numCpus = require('os').cpus().length;
} else { server.listen( port, () => console.log('Server running at http://localhost:' + port) ) }`