cagross opened a new issue #1009:
URL: https://github.com/apache/cordova-android/issues/1009


   # Bug Report
   
   ## Problem
   
   ### What is expected to happen?
   `cordova build android` completes without issue.
   
   
   ### What does actually happen?
   Build fails with the following output:
   
       $ cordova build android
       Unable to load PlatformApi from platform. Error [ERR_REQUIRE_ESM]: Must 
use import to load ES Module: 
C:\Users\snarl\my-project\platforms\android\cordova\Api.js
       require() of ES modules is not supported.
       require() of C:\Users\snarl\my-project\platforms\android\cordova\Api.js 
from 
C:\Users\snarl\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\util.js
 is an ES module file as it is a .js file whose nearest parent package.json 
contains "type": "module" which defines all .js files in that package scope as 
ES modules.
       Instead rename Api.js to end in .cjs, change the requiring code to use 
import(), or remove "type": "module" from 
C:\Users\snarl\my-project\package.json.
       
       Unhandled error. ('The platform "android" does not appear to be a valid 
cordova platform. It is missing API.js. android not supported.')
   
   
   ## Information
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   
   I've built a simple app, which I can build for Android (or browser) without 
issue.  I have now now implemented a simple unit test (using 
[Tape](https://github.com/substack/tape)), which runs in Node.  Since some 
files I'm testing are ES6 modules, in order to run the unit tests in Node, I 
had to add `"type": "module",` to my `package.json` file.  But when I did that, 
my app would no longer build--the Cordova build command fails with the output 
above.  Is it possible to execute the Cordova build for Android--if so, how?
   
   Or is some part of my method flawed in this case? That is certainly a 
possibility.  Maybe if I run unit tests in the browser (rather than in Node), 
this issue will be avoided?
   
   Thanks.
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   
   `cordova build android` (or `cordova build browser`)
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   
   Platforms:  Android, Browser
   
   ### Version information
   Cordova: 9.0.0 ([email protected])
   Cordova Plugins:  cordova-plugin-file, cordova-plugin-network-information, 
cordova-plugin-whitelist
   Other Frameworks: 
   Operating System:  Windows
   
   
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [ X ] I searched for existing GitHub issues
   - [ X ] I updated all Cordova tooling to most recent version
   - [ X ] I included all the necessary information above
   


----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to