jasmine / jasmine-npm

A jasmine runner for node projects.
MIT License
376 stars 145 forks source link

SyntaxError on node < 10 #166

Closed mjeanroy closed 3 years ago

mjeanroy commented 3 years ago

Hi, I would like to report a SyntaxError occuring on node < 10 (so node 9, node 8, et .). Here is the issue:

[...]/node_modules/jasmine/lib/loader.js:25
  return import(path);
         ^^^^^^

SyntaxError: Unexpected token import
    at new Script (vm.js:51:7)
    at createScript (vm.js:136:10)
    at Object.runInThisContext (vm.js:197:10)
    at Module._compile (internal/modules/cjs/loader.js:618:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (internal/modules/cjs/helpers.js:11:18)
npm ERR! Test failed.  See above for more details.

The issue is due to this commit (support added for ES modules).

Before opening an issue, I tried to check in the documentation if there was a note about the supported version of node, but I did not find anything.

Maybe node < 10 is not supported anymore, so this is not an issue, but a note on the documentation should probably be added, and it should have been a major release since it is a breaking change but that's another debate ;)

sgravrock commented 3 years ago

Sorry about that. We try not to break old versions of Node (or Python, or Ruby, or browsers) between major releases. But we also try not to make major releases too frequently, since we leave a noticeable group of users behind with each major release. When the ecosystem moves as quickly as Node does we're sometimes forced to make hard choices. In this case we'd turned off CI builds for some older (past end of life) Node versions due to toolchain bit rot. As a result, I didn't catch the breaking change.

I don't see a way to restore Node <10 support without removing ES module support. (Although I'd be happy to review a pull request that proves me wrong about that.)

We'll try to do a better job of documenting which Node versions are supported and of keeping them working between major releases. Realistically though, there are times when that's just going to mean doing a major release sooner rather than keeping old Node versions going longer.

BTW, Node 8 hit end of life at the end of last year and Node 9 hit end of life in mid 2018. I recommend upgrading, even if it's just to get security updates.

mjeanroy commented 3 years ago

Sorry about that.

That's totally understandable, you don't have to be sorry!

I agree that an app must upgrade to node >= 10, the issue arise when writing a plugin for a tool that should still support node < 10 (such as Babel I guess, gulp, etc.). In this case, I think it is important that a plugin still support the same range of version, but maybe I'm wrong.

Anyway, thanks for the answer, I totally understand your reasons!