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

Use yarn over npm #2

Open
lrkwz opened this issue Jan 15, 2018 · 1 comment
Open

Use yarn over npm #2

lrkwz opened this issue Jan 15, 2018 · 1 comment

Comments

@lrkwz
Copy link

lrkwz commented Jan 15, 2018

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.

@dsyer
Copy link
Owner

dsyer commented Jul 10, 2018

Thanks for the suggestion. I have no personal preference for npm over yarn, but it does seem to me to be more common. I'll leave this issue here in case anyone wants to copy your code.

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

No branches or pull requests

2 participants