Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

236
Views
nodejs @babel/register cannot load plugins in mocha test
  "scripts": {
    "test-1": "mocha --require @babel/register ./src/tests/stage1.spec.js",
    "test-2": "mocha --require @babel/register ./src/tests/stage2.spec.js"
  },
  "dependencies": {
    "@babel/core": "^7.2.2",
    "@babel/node": "^7.2.2",
    "@babel/preset-env": "^7.2.3",
    "chai": "^4.2.0",
    "mocha": "^5.2.0"
  },
  "devDependencies": {
    "@babel/plugin-proposal-optional-chaining": "^7.16.7"
  },
  "babel": {
    "presets": [
      "@babel/preset-env"
    ],
    "plugins": [
      [
        "@babel/plugin-proposal-optional-chaining"
      ]
    ]
  }

Here are most parts of my package.json file, my Node version is 10, after npm run test-1, it will throw an error that

Support for the experimental syntax 'optionalChaining' isn't currently enabled (14:36):

  12 |     let existedIndex = null;
  13 |     this.crops.some((existedCrop, index) => {
> 14 |       if (existedCrop.name === crop?.name) {
     |                                    ^
  15 |         existedIndex = index;
  16 |         return true;
  17 |       }

Add @babel/plugin-proposal-optional-chaining (https://git.io/vb4Sk) to the 'plugins' section of your Babel config to enable transformation.

I have executed npm i before, it seems that this plugin @babel/plugin-proposal-optional-chaining is not correctly loaded by @babel/register.

Where is the mistake?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!