Closed breun closed 2 years ago
I'm currently using Yarn 2 with the frontend-maven-plugin
being configured to use Yarn 1.22.5.
This works because Yarn 2 is installed on a per-project basis.
You can switch to Yarn 2 and install it in you project as detailed here https://yarnpkg.com/getting-started/install.
When frontend-maven-plugin
runs it will install Yarn 1.22.5 every time but this install won't overwrite your projects Yarn 2 version. All yarn
commands will still use your projects Yarn 2 version.
You will get output like:
[INFO] Yarn 2.2.2 was installed, but we need version v1.22.5
[INFO] Installing Yarn version v1.22.5
[INFO] Unpacking /Users/f/.m2/repository/com/github/eirslett/yarn/1.22.5/yarn-1.22.5.tar.gz into /Users/f/my-app/src/main/frontend/node/yarn
[INFO] Installed Yarn locally.
[INFO]
[INFO] --- frontend-maven-plugin:1.10.0:yarn (install node packages) @ my-app ---
[INFO] Running 'yarn install' in /Users/f/my-app/src/main/frontend
[INFO] ➤ YN0000: ┌ Resolution step
[INFO] ➤ YN0000: └ Completed in 0.32s
[INFO] ➤ YN0000: ┌ Fetch step
[INFO] ➤ YN0013: │ @angular-devkit/architect@npm:0.1001.3 can't be found in the cache and will be fetched from the remote registry
[INFO] ➤ YN0013: │ @angular-devkit/build-angular@npm:0.1001.3 can't be found in the cache and will be fetched from the remote registry
...
[INFO] ➤ YN0019: │ fsevents-patch-1813f6d75e-508a7e7e1e.zip appears to be unused - removing
[INFO] ➤ YN0019: │ fsevents-patch-ef2bb5c6ad-0005677b72.zip appears to be unused - removing
[INFO] ➤ YN0000: └ Completed in 2.04m
[INFO] ➤ YN0000: ┌ Link step
[INFO] ➤ YN0008: │ @angular/cli@npm:10.1.3 must be rebuilt because its dependency tree changed
[INFO] ➤ YN0007: │ fsevents@patch:fsevents@npm%3A1.2.13#builtin<compat/fsevents>::version=1.2.13&hash=87eb42 must be built because it never did before or the last one failed
[INFO] ➤ YN0000: └ Completed in 9.13s
[INFO] ➤ YN0000: Done in 2.21m
As you see the plugin installed Yarn 1.22.5 but the yarn install
output is Yarn 2.
It's not ideal but it works for the time being.
I'm currently using Yarn 2 with the
frontend-maven-plugin
being configured to use Yarn 1.22.5. This works because Yarn 2 is installed on a per-project basis.
Hello @fridoo. I've Yarn installed locally on the repo, it works just fine when running a straight yarn install but not thru Maven. Here is my configuration. Anything I'm missing ?
pom.xml:
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.12.0</version>
<configuration>
<nodeVersion>v14.17.6</nodeVersion>
<yarnVersion>v1.16.0</yarnVersion>
<workingDirectory>front-end</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and yarn</id>
<goals>
<goal>install-node-and-yarn</goal>
</goals>
<phase>initialize</phase>
</execution>
<execution>
<id>yarn install</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>compile</phase>
<configuration>
<arguments>install</arguments>
<workingDirectory>front-end</workingDirectory>
</configuration>
</execution>
<execution>
<id>yarn build</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>compile</phase>
<configuration>
<arguments>run build</arguments>
<workingDirectory>front-end</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
.yarnrc.yml:
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
yarnPath: .yarn/releases/yarn-3.0.2.cjs
Maven output:
[INFO] --- frontend-maven-plugin:1.12.0:install-node-and-yarn (default-cli) @ exp-portal ---
[INFO] Node v14.17.6 is already installed.
[INFO] Yarn 1.16.0 is already installed.
[...]
[INFO] --- frontend-maven-plugin:1.12.0:yarn (default-cli) @ exp-portal ---
[INFO] Running 'yarn install' in /Users/rndmerle/Cockpit/portal-trunk/front-end
[INFO] yarn install v1.16.0
[INFO] error An unexpected error occurred: "Unknown token: { [...]
And actually, if I manually run ./node/yarn/dist/bin/yarn
(which is installed by frontend-maven-plugin) it doesn't use the local bin.
Thanks ;)
Ok my bad, I had to configure yarnVersion = v1.22.15 so it supports berry and all. It's now working ;)
Does
frontend-maven-plugin
support Yarn 2? Yarn's migration guide for Yarn 2 is not really clear to me, but mentions Yarn 2 is 'a very different software from the v1'.Do you want to request a feature or report a bug?
If
frontend-maven-plugin
does not support Yarn 2 yet, this is a feature request.What is the current behavior?
Yarn v1 works fine, but I don't know how to use Yarn v2.
Please mention your frontend-maven-plugin and operating system version.
frontend-maven-plugin 1.10.0 on macOS 10.15.6.