You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2020/07/05 03:58:02 UTC

[GitHub] [cordova-android] breautek commented on issue #1009: Cordova build fails if I set 'type: modules' in package.json.

breautek commented on issue #1009:
URL: https://github.com/apache/cordova-android/issues/1009#issuecomment-653838970


   Cordova doesn't support support ES modules as it is still an experimental technology in node js (which means there are likely to be bugs and drastic changes in the API/behaviour)
   
   In fact the error message seems to indicate this is a bug in NodeJS because `node_modules\cordova-lib\src\cordova\util.js` nearest `package.json` file is `node_modules/cordova-lib/package.json`, and it does not have `"type": "module"` in it, therefore I don't think it's suppose to be treated as an ES file. Nor should it be treated as an ES file because none of cordova sources are not ES modules, they are traditional node modules.
   
   As a workaround I'd probably use another tool that transpiles your code into commonjs so that it can be ran in NodeJS for your unit testing. A popular tool for this kind of thing is Babel, and I believe it has the capability of transpiling ES modules into commonjs.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org