cucumber / cucumber-js

Cucumber for JavaScript
https://cucumber.io
MIT License
5.04k stars 1.09k forks source link

Unexpected token '.' in if (prelude[i + 1]?.[0] !== '#' #2282

Closed anafaggiano closed 1 year ago

anafaggiano commented 1 year ago

👓 What did you see?

I got an unexpected token error when trying to run cucumber.js

✅ What did you expect to see?

For cucumber.js to run without errors

📦 Which tool/library version are you using?

cucumber: 9.1.1 node: 16.17.1 npm: 8.19.2

🔬 How could we reproduce it?

Steps to reproduce the behavior:

  1. Install cucumber version 9.1.1
  2. Create a feature file
  3. Configure cucumber as follows:
    
    let common = [
    'features/**.feature',                                                 // Specify feature files
    '--require dist/features/step_definitions/**.steps.js',     // Load step definitions
    '--format progress-bar',                                    // Load custom formatter
    '--publish-quiet',                                          // Don't show results publishing suggestions
    ].join(' ');

module.exports = { default: common, };

4. Run command ./node_modules/.bin/cucumber-js (or wherever your cucumber is) -p default
5. See error 

if (prelude[i + 1]?.[0] !== '#') ^ SyntaxError: Unexpected token '.'



### 📚 Any additional context?

Downgrading to version 8.6.0 fixes it for me

----

*This text was originally generated from a [template](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/about-issue-and-pull-request-templates), then edited by hand. [You can modify the template here.](https://github.com/cucumber/.github/edit/main/.github/ISSUE_TEMPLATE/bug_report.md)*
davidjgoss commented 1 year ago

The error suggests a too-old version of Node.js, maybe 12.x. Can you run in debug mode and post the full output?

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 3 weeks with no activity. Remove the stale label or comment or this will be closed in another 5 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 5 days with no activity.