0

I am trying to package my front-end with my back-end, reactjs and java spring boot. I am getting this error and I can´t find a way to solve it. I got the latest npm, node and react installed.

Here is my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>integritaback</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>integritaback</name>
    <description>Projeto Clinica Integrita</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

    </dependencies>

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

            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.12.1</version>

                <executions>
                    <!-- installing node and npm -->
                    <execution>
                        <id>Install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <nodeVersion>v18.12.1</nodeVersion>
                            <npmVersion>8.19.2</npmVersion>
                        </configuration>
                    </execution>

                    <!-- running npm install -->
                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <arguments>install</arguments>
                        </configuration>
                    </execution>

                    <!-- build our production version -->
                    <execution>
                        <id>npm run build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <nodeVersion>v18.12.1</nodeVersion>
                    <workingDirectory>src/main/Integrita</workingDirectory>
                </configuration>
        </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>Copy JavaScript app into SpringBoot</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>target/classes/static</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/Integrita/build</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

So when I try to run .\mvnw clean install it goes fine until this error appear:

[INFO] --- frontend-maven-plugin:1.11.3:npm (npm install) @ integritaback ---
[INFO] Running 'npm install' in C:\Users\LuisR\Documents\Integrita\integritaback\src\main\Integrita
[INFO] npm ERR! code ERESOLVE
[INFO] npm ERR! ERESOLVE could not resolve
[INFO] npm ERR!
[INFO] npm ERR! While resolving: @react-pdf/renderer@3.0.1
[INFO] npm ERR! Found: react@18.2.0
[INFO] npm ERR! node_modules/react
[INFO] npm ERR!   react@"^18.2.0" from the root project
[INFO] npm ERR!   peer react@">=16.8.0" from @emotion/react@11.10.4
[INFO] npm ERR!   node_modules/@emotion/react
[INFO] npm ERR!     @emotion/react@"^11.10.4" from the root project
[INFO] npm ERR!     peer @emotion/react@"^11.0.0-rc.0" from @emotion/styled@11.10.4
[INFO] npm ERR!     node_modules/@emotion/styled
[INFO] npm ERR!       @emotion/styled@"^11.10.4" from the root project
[INFO] npm ERR!       4 more (@mui/material, @mui/styled-engine, @mui/system, @mui/x-date-pickers)
[INFO] npm ERR!     4 more (@mui/material, @mui/styled-engine, @mui/system, @mui/x-date-pickers)
[INFO] npm ERR!   39 more (@emotion/styled, ...)
[INFO] npm ERR!
[INFO] npm ERR! Could not resolve dependency:
[INFO] npm ERR! peer react@"^16.8.6 || ^17.0.0" from @react-pdf/renderer@3.0.1
[INFO] npm ERR! node_modules/@react-pdf/renderer
[INFO] npm ERR!   @react-pdf/renderer@"^3.0.1" from the root project
[INFO] npm ERR!
[INFO] npm ERR! Conflicting peer dependency: react@17.0.2
[INFO] npm ERR! node_modules/react
[INFO] npm ERR!   peer react@"^16.8.6 || ^17.0.0" from @react-pdf/renderer@3.0.1
[INFO] npm ERR!   node_modules/@react-pdf/renderer
[INFO] npm ERR!     @react-pdf/renderer@"^3.0.1" from the root project
[INFO] npm ERR!
[INFO] npm ERR! Fix the upstream dependency conflict, or retry
[INFO] npm ERR! this command with --force, or --legacy-peer-deps
[INFO] npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
[INFO] npm ERR!
[INFO] npm ERR! See C:\Users\LuisR\AppData\Local\npm-cache\eresolve-report.txt for a full report.
[INFO]
[INFO] npm ERR! A complete log of this run can be found in:
[INFO] npm ERR!     C:\Users\LuisR\AppData\Local\npm-cache\_logs\2023-01-03T12_02_46_084Z-debug-0.log
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  17.384 s
[INFO] Finished at: 2023-01-03T09:02:49-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.11.3:npm (npm install) on project integritaback: Failed to run task: 'npm install' failed. org.apache.commons.exec.Ex
ecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Can anyone help me out. I don´t know what else to do.

  • Your FE has a dependency version conflict that need to be resolved. This could happen if you are using frameworks that are fix to a specific react/.. version but you're using mainly another one. You can now force to overwrite it but that might break the framework in case of breaking changes or load both (not efficient). You should realy resolve it by replacing the tool if needed. Hint given by NPM and the ipe is this line `with --force, or --legacy-peer-deps` – LenglBoy Jan 03 '23 at 12:43
  • The problem looks like to be with @react-pdf/renderer but how to clear the depedency? – Luis Rotoly Jan 03 '23 at 12:52
  • Check your FE dependency list (npm file) and replace `react-render` by the correct one for react 18: `react-18-pdf/renderer` – LenglBoy Jan 03 '23 at 12:55

0 Answers0