Open thomasakarlsen opened 3 months ago
This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed. Please see the Contributing Guide for how to create a Sample App. Thanks! Ionitron 💙
I have added a reproduction repo: https://github.com/thomasakarlsen/capacitor-esm-bug
Regarding the reproduction repo:
It seems like cypress is having a similar issue making it impossible to run yarn install
on it. I have no clue how to fix this.
Again, this repo is just a fresh setup of ionic start --type=vue
so to investigate the specific issue I have talked about here it is best to create a new ionic app locally.
There is something really weird going on with the dependencies here...
Seems like deleting the yarn.lock file and then running yarn install
somehow produces a dependency graph that properly works even without setting @vue/test-utils
to 2.4.0
.
Interestingly this works both for the reproduction repo and if you use ionic start --type=vue
.
Thanks for the issue, but it's an Ionic CLI issue, not a Capacitor issue, I've moved it to the appropriate repository.
The problem is, as you have figured out by now, that something is installing string-width
version 5.x, which is a ESM version and the Ionic CLI doesn't support ESM dependencies.
When you remove the lock file and reinstall, then the 4.x version is installed and your app works.
Ionic CLI would need to be updated to support ESM dependencies for this to be fixed, but also some people mention that using yarn 4 also fixes the issue.
Capacitor Version
(gathered after my temporary fix, see details below)
Latest Dependencies:
@capacitor/cli: 5.7.0 @capacitor/core: 5.7.0 @capacitor/android: 5.7.0 @capacitor/ios: 5.7.0
Installed Dependencies:
@capacitor/android: 5.7.0 @capacitor/ios: not installed @capacitor/cli: 5.7.0 @capacitor/core: 5.7.0
Other API Details
Platforms Affected
Current Behavior
When trying to run
ionic capacitor run android
for the first time in a fresh ionic app the following error appears when the ionic cli reaches the step where thiscapacitor init MyApp io.ionic.starter --web-dir dist
is run:Researching this issue I ran
yarn why string-width
which resulted in:Looking at the recent releases of
@vue/test-utils
I found that in versions2.4.1
and2.4.2
they updated their dependencies. By hard locking my version of@vue/test-utils
to2.4.0
and performing a clean install by deleting myyarn.lock
file andnode_modules
followed byyarn install
I was able to runcapacitor init MyApp io.ionic.starter --web-dir dist
without any errors.Running
yarn why string-width
now results in:I do not know exactly what changed with the dependencies of
@vue/test-utils
after version2.4.0
but something there seems to cause yarn to disregard the manifest of@ionic/utils-terminal
and install major versions of some dependencies that are not supported.Expected Behavior
ionic capacitor run android
or evencapacitor init
works without any errorsThis is my output after locking
@vuejs/test-utils
to version2.4.0
:Project Reproduction
https://github.com/thomasakarlsen/capacitor-esm-bug
Additional Information
I had the same issue as ionic-team/capacitor#7126 and did some more digging to figure out why it was happening. Based on the results of my debugging I am not sure if this is the right package to create the issue for, but it is the
capacitor init
command that fails. Let me know if the issue should be made elsewhere.For anyone else experiencing this issue the temporary solution seems to be locking
@vuejs/test-utils
to version2.4.0
(and doing a clean install of dependencies)