JavaScript Track throws SyntaxError in jest-cli


I tried to solve my first JavaScript exercise locally. It is Elyses Enchantments. Before having added anything I tried to run the test with

npm test

I then get the following error:

> @exercism/javascript-elyses-enchantments@ test /…path_to_exercism/exercism/javascript/elyses-enchantments
> jest ./*

if (error?.stack) {
— — — -^

SyntaxError: Unexpected token .
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/…path_to_exercism/exercism/javascript/elyses-enchantments/node_modules/jest/node_modules/jest-cli/build/index.js:18:12)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
npm ERR! Test failed. See above for more details.

Does anyone know how I can resolve it? I work on ubuntu.

Edit: had to add some --- to make the indicator ^ indicate at the correct position/token.

Hi @RaoulSchikora,

Can you run node -v in a terminal? It should say 18.x.y. If it says a much lower number, please update your node installation (Node.js). If it says an odd version, please install an even version.

The problem here is that your local runner doesn’t understand the syntax yet.

Hey SleeplessByte,

thanks a lot. That was it. I somehow thought I was working on the latest LTS version. But apparently I wasn’t :)

All the best