2

I recently upgraded my app from Angular 12 to 14 and upgraded Jest to version 29.1.2.

When I run Jest, I get the following error:

/myApp/node_modules/jest-cli/build/run.js:129
    if (error?.stack) {
              ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:1054:16)
    at Module._compile (internal/modules/cjs/loader.js:1102:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/tmp/work/web-duttinodefront/web-duttinodefront/code/angular/node_modules/jest-cli/build/index.js:12:12)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@1.0.0 test:ci: `jest`
npm ERR! Exit status 1

The strange thing is that if I run the command on my local machine, Jest runs perfectly, but if it runs through a Github workflow, that's when it fails.

Both on my local machine and in the Github workflow setup, I'm using node 16.10.

Need some help!

1 Answers1

1

I had the same error on the same line, and it looks like just a NodeJS version error, related to conditionals. See the ? in error (error?.stack). I updated my NodeJS version to 16 and it resolved this error, but version 14 should suffice.

Here you can find the answer where I found the solution. Original ques

Make sure your NodeJS version on Github is also 16.

David Reis
  • 26
  • 2