node.jsangularrollupjsvitest

Vitest : cannot find package 'rollup'


While trying to execute unit tests with Vitest through Yarn in my Angular app I have an error about 'rollup' package :

yarn run test
[INFO] failed to load config from xxx\angular-test\vitest.config.ts
[INFO] An unhandled exception occurred: Cannot find package 'rollup' imported from xxx\angular-test\.yarn\__virtual__\vite-virtual-35af3c8a63\13\Users\wwww\AppData\Local\Yarn\Berry\cache\vite-npm-6.3.5-244c1b4d55-10c0.zip\node_modules\vite\dist\node\index.js
[INFO] Did you mean to import "rollup/dist/parseAst.js"?

Context:


Solution

  • I saw some Github issues related to this failure :

    but none of them was working.

    Even if Node 22.13.0 is compatible with Angular 20 (https://angular.dev/reference/versions#actively-supported-versions), the failure was fixed by using a newer version of Node : v24.2.0