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

[email protected] does not work with babel-register and spawn #599

Closed
mysticatea opened this issue Jun 9, 2017 · 9 comments
Closed

[email protected] does not work with babel-register and spawn #599

mysticatea opened this issue Jun 9, 2017 · 9 comments

Comments

@mysticatea
Copy link

mysticatea commented Jun 9, 2017

Please use the template provided below, when reporting bugs:

[email protected] seems to fail child_process.exec with --require babel-register. Example: https://travis-ci.org/mysticatea/cpx/jobs/241057845#L891

$ nyc --require babel-register npm run -s _mocha

Expected Behavior

No errors.

Observed Behavior

The following error looks to be thrown from spawn-wrap of nyc.

SyntaxError: /home/travis/.node-spawn-wrap-2050-e08970c6c6a6/node: 'return' outside of function (120:2)
    118 |   debug('no main file!', args)
    119 |   foregroundChild(node, args)
  > 120 |   return
        |   ^
    121 | }
    122 | 
    123 | // If there are execArgv, and they're not the same as how this module
      at Parser.pp$5.raise (/home/travis/build/mysticatea/cpx/node_modules/babel-register/node_modules/babel-core/node_modules/babylon/lib/index.js:4454:13)
      at ...

Bonus Points! Code (or Repository) that Reproduces Issue

Forensic Information

Operating System:

  • Linux (Travis CI), and OSX (Travis CI), and Windows 7.

Environment Information:

  1. run the following script:

sh -c 'node --version; npm --version; npm ls' > output.txt

  1. share a gist with the contents of output.txt.
'sh' is not recognized as an internal or external command,
operable program or batch file.

My machine is Windows 😄
Please see Travis CI log about environment.

@mysticatea
Copy link
Author

mysticatea commented Jun 9, 2017

After I pinned nyc at 11.0.1, this problem disappeared. So this is a regression bug of [email protected].

@bcoe
Copy link
Member

bcoe commented Jun 10, 2017

@mysticatea the only difference between 11.0.1 and 11.0.2 was that spawn-wrap was upgraded.

I can't seem to immediately reproduce the issue myself:

./node_modules/.bin/nyc --require babel-register --reporter=html node lib/yarsay.js

can you provide a repo of the specific problem, also it would be helpful if you opened a pull request on the spawn-wrap repository.

@mysticatea
Copy link
Author

mysticatea commented Jun 10, 2017

lib/yarsay.js looks to not use child_process.exec.

This is a simple repro code:

// test.js
const exec = require("child_process").exec

if (process.argv[2] !== "child") {
  console.log("parent")
  exec(`node "${process.argv[1]}" child`, { stdio: "inherit" }, (err) => {
    console.error(err)
  })
}
else {
  console.log("child")
}
$ ./node_modules/.bin/nyc --require babel-register node test.js

@jeffijoe
Copy link

jeffijoe commented Jun 22, 2017

Running into this when testing with AVA which uses Babel. I'm on macOS. :)

@bcoe
Copy link
Member

bcoe commented Jun 25, 2017

@bcoe
Copy link
Member

bcoe commented Jun 25, 2017

@hzoo is the inability to return at the top level intentional on babylon's part; trying to figure out whether @isaacs and I should fix this in spawn-wrap or Babylon?

@bcoe
Copy link
Member

bcoe commented Jun 25, 2017

@jeffijoe @mysticatea please give this a try:

npm i nyc@next

the next release of nyc lands a fix for this.

@mysticatea
Copy link
Author

Thank you. I confirmed that nyc@next fixed this issue.

@toddpi314
Copy link

Confirmed this resolves issue for me too, different reproduction scenario revolving around spawn.

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

Successfully merging a pull request may close this issue.

4 participants