2

I'm new to this topic and stuck for two days so I would really appreciate your help. I'm trying to connect my Spring Boot to React. But I don't have package.json created anywhere just a node folder.

My steps:

  1. I create Spring Boot 3.0.4 project with a Spring Web and Mustache dependencies. Maven. Java 17.
  2. Add frontend-maven-plugin to pom.xml. Save and reload pom.xml. Here is how my plugins section looks like:
<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>
    <execution>
      <goals>
         <goal>install-node-and-npm</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <nodeVersion>v16.14.2</nodeVersion>
  </configuration>
</plugin>
  1. Run ./mvnw generate-resources in a root folder
➜  mate ./mvnw generate-resources
[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------------< com.check:mate >---------------------------
[INFO] Building mate 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- frontend-maven-plugin:1.12.1:install-node-and-npm (default) @ mate ---
[INFO] Installing node version v16.14.2
[INFO] Unpacking /Users/service/.m2/repository/com/github/eirslett/node/16.14.2/node-16.14.2-darwin-x64.tar.gz into /Users/service/Documents/mate/node/tmp
[INFO] Copying node binary from /Users/service/Documents/mate/node/tmp/node-v16.14.2-darwin-x64/bin/node to /Users/service/Documents/mate/node/node
[INFO] Extracting NPM
[INFO] Installed node locally.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.705 s
[INFO] Finished at: 2023-03-13T01:07:08-07:00
[INFO] ------------------------------------------------------------------------

  1. I run node/npm install --save-dev parcel in root folder
➜  mate node/npm install --save-dev parcel

up to date, audited 210 packages in 1s

76 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
  1. Add a new execution to pom.xml
<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>
    <execution>
      <goals>
         <goal>install-node-and-npm</goal>
      </goals>
    </execution>
    <execution>
      <id>npm install</id>
      <goals>
        <goal>npm</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <nodeVersion>v16.14.2</nodeVersion>
  </configuration>
</plugin>

The guide I follow mentions I have to have package.json by this moment. But I have no, just node folder. What am i probably doing wrong? Thanks

screenshot

1 Answers1

1

I just ran the same steps and was able to generate a basic package.json file. It should be inside the node folder.

Here are the contents of the file:

{
  "devDependencies": {
    "parcel": "^2.9.2"
  }
}
DevNight89
  • 33
  • 9