cameron1024
cameron1024

Reputation: 10156

Vaadin Spring Boot cannot find npm packages

I have an existing Spring Boot application that I am looking to add a Vaadin frontend to.

I have a simple view class that is as follows:

@Route(value = "admin")
public class MainView extends VerticalLayout {

    private TextField field = new TextField("Message");
    private Button button = new Button("Click Me");

    @PostConstruct
    public void init() {
        button.addClickListener(e -> Notification.show("Message: " + field.getValue()));
    }
}

I have disabled Spring Security by adding .anyRequsts().permitAll() to my SecurityConfig

When I run the application, and navigate to /admin in Chrome, I get the following error displayed where the page is meant to be.:

Webpack Error

ERROR in ../target/frontend/generated-flow-imports.js
Module not found: Error: Can't resolve '@vaadin/vaadin-button/src/vaadin-button.js' in 'C:\Users\cameron\IdeaProjects\biometric-access\target\frontend'
 @ ../target/frontend/generated-flow-imports.js 11:0-52

This is repeated a few times for various packages. I also get a similar error in the Spring console output. It also gives a message telling me to delete node_modules, and run npm install, which I have tried.

The Vaadin docs mention nothing about this issue, and the reccomended steps do not work.

Infuriatingly, It worked as normal previously, and I don't know what change made it stop working. Any advice would be appreciated.

EDIT

After some searching, I realised it was probably an npm issue rather than a vaadin issue. The npm "common issues" page recommends running npm clean followed by npm install to solve this error. This solved my problem.

Upvotes: 2

Views: 1669

Answers (1)

d2k2
d2k2

Reputation: 712

I had the same problem after updating from Vaadin 14.0.0 to 14.0.2 . Deleting the node_modules folder and running prepare-frontend goal is not enough.

Delete following files and folders before packaging your project:

  • node_modules
  • package-lock.json
  • package.json
  • webpack.config.js
  • webpack.generated.js

Would be nice to have something like a "clean" goal to do this automatically after updating the vaadin version in the pom.xml

Upvotes: 3

Related Questions