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

Incompatible option for yarn v2 #4483

Open
psydvl opened this issue Jul 11, 2020 · 7 comments · May be fixed by #4892 or #5034
Open

Incompatible option for yarn v2 #4483

psydvl opened this issue Jul 11, 2020 · 7 comments · May be fixed by #4892 or #5034
Labels

Comments

@psydvl
Copy link

psydvl commented Jul 11, 2020

Description:
ionic start command broken with Yarn v2 (aka berry).

Steps to Reproduce:

$ yarn set version berry
$ echo n | ionic start Test blank --type=angular

Or even:

$ yarn set version berry
$ echo n | yarn dlx -p @ionic/cli ionic start Test blank --type=angular

Output:

> yarn install --non-interactive
Unknown Syntax Error: Unsupported option name ("--non-interactive").

$ yarn install [--json] [--immutable] [--immutable-cache] [--check-cache] [--inline-builds]
[ERROR] An error occurred while running subprocess yarn.
        
        yarn install --non-interactive exited with exit code 1.
        
        Re-running this command with the --verbose flag may provide more
        information.

My ionic info:

[WARN] You are not in an Ionic project directory. Project context may be missing.
Ionic:
   Ionic CLI : 6.10.1
Utility:
   cordova-res : not installed
   native-run  : not installed
System:
   NodeJS : v14.5.0
   npm    : 6.14.5
   OS     : Linux 5.7

Other Information:
Migration guide: https://yarnpkg.com/advanced/migration

@jay-babu
Copy link

any update on this issue?

@Andorbal
Copy link

Andorbal commented Mar 9, 2022

I just ran into this issue as well. Is there a workaround or is the Ionic cli currently unusable with Yarn Berry?

@Andorbal
Copy link

Andorbal commented Mar 9, 2022

In case it helps anyone, I got a workaround going by temporarily changing the package manager back to npm in ~/.ionic/config.json, then running ionic capacitor add ios to add the iOS project. After that, I switched back to yarn and ran yarn install in the app directory (which removed the node modules folder). I was not able to run ionic capacitor open ios after that, but yarn capacitor open ios seems to work. That made me wonder if running yarn capacitor add ios would have worked, but I'm past that now :)

-- UPDATE --
Turns out, my original approach didn't work because it seemed to use Capacitor v2 to create the iOS project, which didn't work because it was expecting files to be in the node_modules folder, which doesn't exist. My package.json file had Capacitor v3 listed, which doesn't use npm packages for native files. So I removed the iOS folder created by my original command and ran yarn capacitor add ios and that worked: I was able to open the project in Xcode and was able to build and run it in the simulator. Whew...

@wmadden
Copy link

wmadden commented Jun 23, 2022

Any update here?

@Losses
Copy link

Losses commented Jul 19, 2022

2 years later...

Losses added a commit to Losses/ionic-cli that referenced this issue Jul 19, 2022
This pull request enables user to use yarn berry (aka yarn v2 and yarn v3) as their package manager, and fixed ionic-team#4483
@Losses Losses linked a pull request Jul 19, 2022 that will close this issue
@Losses
Copy link

Losses commented Jul 19, 2022

A pull request was made to fix this issue...

@Losses
Copy link

Losses commented Sep 6, 2022

So, it seems nobody care about yarn berry, if you are facing this problem, simply create a patch file on .yarn/patches/@ionic-cli-npm-6.20.1-53fb01ed2a.patch, the content should be:

diff --git a/lib/utils/npm.js b/lib/utils/npm.js
index 640e88d400afdeef85b3859e02eaad97f5c29b9f..4443315d2fbfeeca941ca9cb1cf8b7a474b8170c 100644
--- a/lib/utils/npm.js
+++ b/lib/utils/npm.js
@@ -42,7 +42,7 @@ async function pkgManagerArgs(npmClient, options) {
             vocab = { run: 'run', install: 'i', bareInstall: 'i', uninstall: 'uninstall', dedupe: 'dedupe', rebuild: 'rebuild', global: '-g', save: '--save', saveDev: '-D', saveExact: '-E', nonInteractive: '', lockFileOnly: '--package-lock-only' };
             break;
         case 'yarn':
-            vocab = { run: 'run', install: 'add', bareInstall: 'install', uninstall: 'remove', dedupe: '', rebuild: 'install', global: '', save: '', saveDev: '--dev', saveExact: '--exact', nonInteractive: '--non-interactive', lockFileOnly: '' };
+            vocab = { run: 'run', install: 'add', bareInstall: 'install', uninstall: 'remove', dedupe: '', rebuild: 'install', global: '', save: '', saveDev: '--dev', saveExact: '--exact', nonInteractive: '', lockFileOnly: '' };
             if (options.global) { // yarn installs packages globally under the 'global' prefix, instead of having a flag
                 installerArgs.push('global');
             }

Then, change your version code of @ionic/cli in package.json with: patch:@ionic/cli@npm:6.20.1#.yarn/patches/@ionic-cli-npm-6.20.1-53fb01ed2a.patch.

run yarn to apply the patch, your @ionic/cli will play well with Yarn Berry, just like a magic.

Good luck and have a nice day.

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

Successfully merging a pull request may close this issue.

5 participants