Reputation: 1477
How can I translate var exec = require('child_process').exec
;
to ES6? I know the following: import exec from 'child_process';
What I don't know is how to add the .exec
at the end to the ES6 syntax.
Upvotes: 3
Views: 3793
Reputation: 7742
How can I translate var exec = require('child_process').exec; to ES6?
You do:
import { exec } from 'child_process';
I know the following: import exec from 'child_process';
That's actually wrong, it is as I've done above. More on import
here.
Otherwise, is simply:
import child_process from 'child_process';
const exec = child_process.exec;
You CANNOT do anything like:
import exec from 'child_process'.exec;
Upvotes: 7