Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"SyntaxError: Unexpected token {" in Typescript Express #271

Open
utmishra opened this issue May 17, 2021 · 2 comments
Open

"SyntaxError: Unexpected token {" in Typescript Express #271

utmishra opened this issue May 17, 2021 · 2 comments
Labels
pinned Issues that will not be automatically closed

Comments

@utmishra
Copy link

utmishra commented May 17, 2021

Describe the bug

import swaggerJsDoc from 'swagger-jsdoc';
const options = {
  "definition": {
    "openapi": "3.0.0",
    "info": {
      "title": "Hello World",
      "version": "1.0.0"
    }
  },
  "apis": ['./src/routes*.js'],
};

const openapiSpecification = swaggerJsDoc(options);

Setting the above simple default specification on Typescript based Express throws the following error:

import { prepare, extract, organize, finalize } from './src/specification.js';
       ^

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.<anonymous> (/Users/utmishra/dev/projects/stories/authentication/src/app.ts:22:1)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Module.m._compile (/Users/utmishra/dev/projects/stories/authentication/node_modules/ts-node/src/index.ts:1056:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/Users/utmishra/dev/projects/stories/authentication/node_modules/ts-node/src/index.ts:1059:12)
    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.<anonymous> (/Users/utmishra/dev/projects/stories/authentication/src/index.ts:2:1)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Module.m._compile (/Users/utmishra/dev/projects/stories/authentication/node_modules/ts-node/src/index.ts:1056:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/Users/utmishra/dev/projects/stories/authentication/node_modules/ts-node/src/index.ts:1059:12)

To Reproduce
Steps to reproduce the behaviour:

  1. Run a Typescript Node package with swagger-jsdoc installed

Package version: ^7.0.0-rc.6

Expected behaviour
The app runs without throwing an error

Additional context
Current workaround:

@masives
Copy link

masives commented May 20, 2021

Had same issue, downgrading 6.0.1 fixed it

@stale
Copy link

stale bot commented Jul 19, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 19, 2021
@daniloab daniloab added the pinned Issues that will not be automatically closed label Jul 19, 2021
@stale stale bot removed the wontfix label Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pinned Issues that will not be automatically closed
Projects
None yet
Development

No branches or pull requests

3 participants