#Jest encountered an unexpected token

13 messages · Page 1 of 1 (latest)

cerulean creek
#

Hello Guys,
I updated one dependency(@aws-sdk/client-s3) for my project and started getting this error

Test suite failed to run

    Jest encountered an unexpected token

    Details:

    /Users/asing13/WebstormProjects/ScanItRepos/document-service/node_modules/@aws-sdk/client-s3/dist-cjs/endpoint/EndpointParameters.js:7
            useFipsEndpoint: options.useFipsEndpoint ?? false,
                                                      ^

    SyntaxError: Unexpected token '?'

      at Runtime.createScriptFromCode (../node_modules/jest-runtime/build/index.js:1350:14)
      at Object.<anonymous> (../node_modules/@aws-sdk/client-s3/dist-cjs/S3Client.js:18:30)
feral mortar
#

Node version?

cerulean creek
#

12.18.3

feral mortar
#

Are you on nest 10?

cerulean creek
#

no its 8.2.6

feral mortar
#

Hmm, jest version? And to double check, what does npx nest info print out?

cerulean creek
#

Jest is 26.4.2

[System Information]
OS Version     : macOS
NodeJS Version : v12.20.0
NPM Version    : 6.14.8 

[Nest CLI]
Nest CLI Version : 8.2.6 

[Nest Platform Information]
platform-express version : 8.4.7
schematics version       : 8.0.11
terminus version         : 8.0.8
swagger version          : 5.2.1
testing version          : 8.4.7
common version           : 8.4.7
config version           : 2.1.0
axios version            : 0.0.7
core version             : 8.4.7
cli version              : 8.2.6
feral mortar
#

Okay. Then I can only assume that the aws library you're using doesn't support node 12, due to a syntax difference

cerulean creek
#

My project uses Snyk to monitor for dependency vulnerabilities as one of the pre-build steps for deployment.
I will have to upgrade this aws dependency to move forward

#

any other solution without upgrading node and nest version ?

feral mortar
#

I'm pretty sure this error comes from invalid node 12 syntax.

#

You could theoretically use Babel to transport node 14+ features bank to node 12 compatible, but that seems very hacky

cerulean creek
#

seems upgrading to v14 is the only option