Skip to content

Use yarn over npm #2

Description

@lrkwz

Yarn is much better than npm.

You should include in the pom.xml

<build>
    ...
        <plugin>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <version>1.6</version>
            <configuration>
                <nodeVersion>v8.8.1</nodeVersion>
            </configuration>
            <executions>
                <execution>
                    <id>install node and yarn</id>
                    <goals>
                        <goal>install-node-and-yarn</goal>
                    </goals>
                    <configuration>
                        <nodeVersion>v8.9.4</nodeVersion>
                        <yarnVersion>v1.3.2</yarnVersion>
                    </configuration>
                </execution>

                <execution>
                    <id>yarn install</id>
                    <goals>
                        <goal>yarn</goal>
                    </goals>
                    <configuration>
                        <arguments>install</arguments>
                    </configuration>
                </execution>
            </executions>
        </plugin>
</plugins>
</build>

Then as you create a local npm executable you can create a local yarn using this nippet

#!/bin/sh
cd $(dirname $0)
"node/yarn/dist/bin/yarn" "$@"

all ./npm install can now be replaced with ./yarn add.

Yarn generates a package.json when it installs first type angular-cli then the ng tool refuses to create the new app; so you should rename package.json before calling ./ng new client.

The test block in pom.xml should appear as:

                <execution>
                    <id>yarn-build</id>
                    <goals>
                        <goal>yarn</goal>
                    </goals>
                    <configuration>
                        <arguments>run build</arguments>
                    </configuration>
                </execution>

BTW in your readme the block

		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
		</plugin>

is repeated twice.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions