A common pattern we use in projects is “mvn clean install” from the command line, and then go to IntelliJ and click “Debug using HotswapAgent”. This often (but seems not always weirdly enough) results in below exception during startup:
ERROR(TypeScript) Cannot find module '@vaadin/router' or its corresponding type declarations.
FILE /home/user/src/app/src/main/frontend/generated/index.ts:14:24
12 |
13 | // import Vaadin client-router to handle client-side and server-side navigation
> 14 | import { Router } from '@vaadin/router';
| ^^^^^^^^^^^^^^^^
15 |
16 | // import Flow module to enable navigation to Vaadin server-side views
17 | import { Flow } from 'Frontend/generated/jar-resources/Flow.js';
[TypeScript] Found 1 error. Watching for file changes.
Initializing Servlet 'dispatcherServlet'
Completed initialization in 3 ms
[vite] (client) Pre-transform error: Failed to resolve import "@vaadin/router" from "src/main/frontend/generated/index.ts". Does the file exist?
Plugin: vite:import-analysis
File: /home/user/app/src/main/frontend/generated/index.ts:14:23
1 | import { Router } from "@vaadin/router";
| ^
2 | import { Flow } from "Frontend/generated/jar-resources/Flow.js";
3 | const { serverSideRoutes } = new Flow({
[vite] Internal server error: Failed to resolve import "@vaadin/router" from "src/main/frontend/generated/index.ts". Does the file exist?
Plugin: vite:import-analysis
File: /home/user/app/src/main/frontend/generated/index.ts:14:23
1 | import { Router } from "@vaadin/router";
| ^
2 | import { Flow } from "Frontend/generated/jar-resources/Flow.js";
3 | const { serverSideRoutes } = new Flow({
EDIT seems it’s not related to the commandline build, also when doing a “Rebuild project” in IntelliJ the same error happens.