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

Unexpected token export #315

Open
ianonymousdev opened this issue Mar 6, 2022 · 3 comments
Open

Unexpected token export #315

ianonymousdev opened this issue Mar 6, 2022 · 3 comments

Comments

@ianonymousdev
Copy link

I am using this module in a NodeJS application. When I try to build the project it throws the following error. I am not sure what is wrong. Any help would be appreciated. I am using next with babel. thanks

/Users/irfan/Projects/sourcetree/swapwise/swapwise-web-app/node_modules/astronomia/data/vsop87Bearth.js:2611
export default m;
^^^^^^

SyntaxError: Unexpected token export
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/irfan/Projects/sourcetree/swapwise/swapwise-web-app/node_modules/babel-register/lib/node.js:152:7)
    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/irfan/Projects/sourcetree/swapwise/swapwise-web-app/node_modules/date-holidays-parser/lib/vsop87Bearth.cjs:5:21)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/irfan/Projects/sourcetree/swapwise/swapwise-web-app/node_modules/babel-register/lib/node.js:152:7)
    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)

@bogdanhotea-doctari
Copy link

Hi @commenthol ,

I've the same issue after I've update from 3.14.2 to 3.14.8 I've tried to enable es modules suport for Jest, but with no luck.
Is there any way to get rid of this issue ?

Regards,
Bogdan

@Borales
Copy link

Borales commented Jun 10, 2022

For Jest - I managed to make it work with this jest config:

    "moduleNameMapper": {
      "(astronomia|caldate)": "<rootDir>/node_modules/$1/lib/index.cjs",
      "^date-(.*)": "<rootDir>/node_modules/date-$1/lib/index.cjs"
    }

It basically forces the node to use cjs files instead of module js-files.

@bogdanhotea-doctari
Copy link

For Jest - I managed to make it work with this jest config:

    "moduleNameMapper": {
      "(astronomia|caldate)": "<rootDir>/node_modules/$1/lib/index.cjs",
      "^date-(.*)": "<rootDir>/node_modules/date-$1/lib/index.cjs"
    }

It basically forces the node to use cjs files instead of module js-files.

Works like a charm!
Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants