Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Error: spawn UNKNOWN" #108

Closed
Daniel15 opened this issue Aug 27, 2016 · 4 comments
Closed

"Error: spawn UNKNOWN" #108

Daniel15 opened this issue Aug 27, 2016 · 4 comments
Labels
bug Confirmed bug

Comments

@Daniel15
Copy link
Member

Daniel15 commented Aug 27, 2016

When trying to use the CLI version:

node_modules\.bin\babili.cmd -d .

internal/child_process.js:298
    throw errnoException(err, 'spawn');
    ^

Error: spawn UNKNOWN
    at exports._errnoException (util.js:856:11)
    at ChildProcess.spawn (internal/child_process.js:298:11)
    at Object.exports.spawn (child_process.js:367:9)
    at Object.<anonymous> (C:\temp\babilitest\node_modules\babili\lib\index.js:16:25)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)

Windows 10, Node v5.7.1 (I should probably upgrade Node, guess)

@Daniel15
Copy link
Member Author

It works if I run Babel directly:

node_modules\.bin\babel.cmd --presets=babili in\test.js

function helloWorld(){foo()}helloWorld();

@hzoo hzoo added the bug Confirmed bug label Aug 27, 2016
@hzoo
Copy link
Member

hzoo commented Aug 27, 2016

import child from "child_process";

const args = process.argv.slice(2).concat(["--presets=babili"]);

const opts = {
  stdio: "inherit",
  env: process.env,
};

child.spawn(require.resolve("babel-cli/bin/babel"), args, opts);

must be an issue with child.spawn like in lerna?

@Daniel15
Copy link
Member Author

Daniel15 commented Aug 27, 2016

Yeah... Windows doesn't use shebangs, so executing a JavaScript file directly won't work, even with the #!/usr/bin/env node at the top of the file. Instead, you'll probably have to execute node directly:

import child from "child_process";

const args = [
  require.resolve("babel-cli/bin/babel"),
  ...process.argv.slice(2),
  "--presets=babili"
];

const opts = {
  stdio: "inherit",
  env: process.env,
};

child.spawn('node', args, opts);

That is, run node babel-cli/bin/babel.js rather than just babel-cli/bin/babel. It should work the same as what it's currently doing.

@hzoo
Copy link
Member

hzoo commented Aug 27, 2016

Ok cool didn't know that - do you want to pr that one? Feel free to add anything else - the cli is for convenience if you don't want to use "babel" itself (although that's all it's doing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants