I\'m working on a simple nodejs electron (formerly known as atom shell) project. I\'m writing it using angular 2, using the project the same project setup as they recommend
For me it worked with the callback to display the results.
import * as child from 'child_process';
var foo: child.ChildProcess = child.exec('dir', (error: string, stdout: string, stderr: string) => {
console.log(stdout);
});
I didn't add any mappings in SystemJS as I dont have any such configuration in the node application
If the error message is 'Cannot find module 'child_process' or its corresponding type declarations' the answer is 'npm install @types/watch'
Ok, after some research #L138 I have found the solution
You can use import
as before
import * as child from 'child_process';
var foo: child.ChildProcess = child.exec('foo.sh');
console.log(typeof foo.on);
But you should configure SystemJS
to map the module to NodeJS
.
System.config({
map: {
'child_process': '@node/child_process'
}
});
That's it!