es-spawn =======
Last updated 4 years ago by hollowdoor .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install es-spawn 
SYNC missed versions from official npm registry.



npm install --save es-spawn



import path from 'path';

function p(){
    return new Promise((resolve, reject)=>{
            resolve(path.join(__dirname, __filename))

async function myAsync(){

    let val = await p();
    console.log('The current path is ', val);



import spawn from 'es-spawn';
//const fork = require('es-spawn'); //Using commonjs

    //Nothing needs to be done here
    //unless you want you want to use ipc messaging.
    console.log('test ERROR ',err);


The interface for es-spawn is identical to node's child_process spawn. The only exception is that only javascript files can be used. In other words es-spawn works like a fork of a node process.

spawn(command, argv, options) -> child_process

You can run the fork as if you were using require('child_process').spawn.


es-spawn uses rollup, and babel.

rollup is used to compile es2015 modules in your script to commonjs require type modules.

babel is used to compile async functions down to generators.

These are the basic steps that es-spawn goes through when running a script.

  1. A temporary file is created, and the source script is read.
  2. The source script is compiled with rollup, and babel.
  3. Globals are altered to make the script string look like it's source.
  • __filename
  • __dirname
  • process.arg[1] = __filename
  1. The new script string is written to the temporary file.
  2. The path of the temporary file is passed to child_process.fork()

The most recent version of nodejs uses almost all of es2015. For this reason only es2015 modules, and stage-3 presets are compiled by es-spawn.

You can still use a .babelrc file to get more out of babel. Place a .babelrc file in the directory that contains the file you want to run with es-spawn.

If you want polyfills you should use ponyfills instead. Though most es2015 build-ins are supported by the latest node version. You can use the babel polyfills as well.

Happy coding!

Current Tags

  • 1.0.9                                ...           latest (4 years ago)

10 Versions

  • 1.0.9                                ...           4 years ago
  • 1.0.8                                ...           4 years ago
  • 1.0.7                                ...           4 years ago
  • 1.0.6                                ...           4 years ago
  • 1.0.5                                ...           4 years ago
  • 1.0.4                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 1
Dev Dependencies (1)
Dependents (1)

Copyright 2014 - 2016 © |