swagger-jsdoc icon indicating copy to clipboard operation
swagger-jsdoc copied to clipboard

Cannot use import statement outside a module

Open tridungle opened this issue 3 years ago • 8 comments

Describe the bug [email protected]

To Reproduce Steps to reproduce the behavior:

  1. install
  2. config swagger with swagger-jsdoc
  3. start the server
  4. See error

Screenshots

/node-boilerplate//node_modules/swagger-jsdoc/index.js:1
import { prepare, extract, organize, finalize } from './src/specification.js';
^^^^^^
SyntaxError: Cannot use import statement outside a module
    at Module._compile (internal/modules/cjs/loader.js:895:18)
    at Module._compile (/node-boilerplate/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Object.newLoader [as .js] (/node-boilerplate/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)

tridungle avatar Mar 23 '21 07:03 tridungle

same for me...

cesco69 avatar Mar 29 '21 13:03 cesco69

same issue.

Leehee1on avatar Mar 31 '21 03:03 Leehee1on

yes, i also got this error, does anyone know how to fix?

datnguyen199 avatar Apr 04 '21 04:04 datnguyen199

Why would you convert cjs module to es when it is probably designed to be used with node where majority of stuff is cjs?

akshay-nm avatar Apr 08 '21 23:04 akshay-nm

I also faced the same Issue. I solved this issue temporarily by downgrading the version from v7 to v6 using npm i [email protected]

rahulmathews avatar Apr 19 '21 02:04 rahulmathews

@rahulmathews thank you, it also solved this for me

datnguyen199 avatar Apr 21 '21 04:04 datnguyen199

plz fix

HappyZombies avatar Apr 27 '21 18:04 HappyZombies

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[bot] avatar Jun 26 '21 19:06 stale[bot]