Unexpected token export
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)
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
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.
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
cjsfiles instead ofmodulejs-files.
Works like a charm! Thanks a lot!