vitest-dev / vscode

VS Code extension for Vitest
https://vitest.dev/vscode
MIT License
736 stars 83 forks source link

Error: Cannot find module @rollup/rollup-darwin-x64 on MAC with M3 processor #435

Closed badiuoanaalexandra closed 1 month ago

badiuoanaalexandra commented 1 month ago

Describe the bug

I installed vitest extension and I get error "Error: Vitest failed to start: Error: Cannot find module @rollup/rollup-darwin-x64" I have an Apple M3 Pro processor and cannot install @rollup/rollup-darwin-x64 lib. I tried installing @rollup/rollup-darwin-arm64, but that didn't fix the issue.

Reproduction

Install latest version of vitest extension v1.0.1, vite 5.3.3 and vitest 2.0.1 on a MAC that uses M3 processor, OS darwin and arm64 CPU. Start VSCode.

You'll see error in the Output. Deleting package lock and node modules and running "npm i" again doesn't fix issue. Error: Vitest failed to start: Error: Cannot find module @rollup/rollup-darwin-x64. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try npm i again after removing both package-lock.json and node_modules directory. at requireWithFriendlyError (/Users/oana.badiu/Code/directions-debug-v2/node_modules/rollup/dist/native.js:59:9) at Object. (/Users/oana.badiu/Code/directions-debug-v2/node_modules/rollup/dist/native.js:68:76) at Module._compile (node:internal/modules/cjs/loader:1378:14) at Module._extensions..js (node:internal/modules/cjs/loader:1437:10) at Module.load (node:internal/modules/cjs/loader:1212:32) at Module._load (node:internal/modules/cjs/loader:1028:12) at cjsLoader (node:internal/modules/esm/translators:359:17) at ModuleWrap. (node:internal/modules/esm/translators:308:7) at ModuleJob.run (node:internal/modules/esm/module_job:218:25) at async ModuleLoader.import (node:internal/modules/esm/loader:323:24) at ChildProcess.f (/Users/oana.badiu/.vscode/extensions/vitest.explorer-1.0.1/dist/extension.js:18:5548) at ChildProcess.emit (node:events:514:28) at emit (node:internal/child_process:951:14) at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

Output

Error: Vitest failed to start: 
Error: Cannot find module @rollup/rollup-darwin-x64. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
    at requireWithFriendlyError (/Users/oana.badiu/Code/directions-debug-v2/node_modules/rollup/dist/native.js:59:9)
    at Object.<anonymous> (/Users/oana.badiu/Code/directions-debug-v2/node_modules/rollup/dist/native.js:68:76)
    at Module._compile (node:internal/modules/cjs/loader:1378:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1437:10)
    at Module.load (node:internal/modules/cjs/loader:1212:32)
    at Module._load (node:internal/modules/cjs/loader:1028:12)
    at cjsLoader (node:internal/modules/esm/translators:359:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:308:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
    at ChildProcess.f (/Users/oana.badiu/.vscode/extensions/vitest.explorer-1.0.1/dist/extension.js:18:5548)
    at ChildProcess.emit (node:events:514:28)
    at emit (node:internal/child_process:951:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

Version

v1.0.1

Validations

sheremet-va commented 1 month ago

Does Vitest work for you without the extension?

badiuoanaalexandra commented 1 month ago

Running vitest in the terminal without the extension works fine.

badiuoanaalexandra commented 1 month ago

If it helps, vitest extension version v0.5.15 used to work when using vitest 1.4.0, however this version of the extension is not available anymore for download it seems and also it doesn't work with vitest latest 2.0.1

sheremet-va commented 1 month ago

It doesn't really help. I don't think the problem is with OS, I will need a minimal reproduction to looks into this. Try creating a simple project - does it work on your PC out of the box?

badiuoanaalexandra commented 1 month ago

The extension does work with the simple project so must be something in my repo that is causing it to crash. Weird that this didn't happen with v0.5.15. I'll look more into it on my side. Thanks for the quick response.

sheremet-va commented 1 month ago

The extension does work with the simple project so must be something in my repo that is causing it to crash. Weird that this didn't happen with v0.5.15. I'll look more into it on my side. Thanks for the quick response.

Maybe you don't have the config in the root? The extension uses the config directory as cwd, - maybe that's why it can't find the package?

badiuoanaalexandra commented 1 month ago

I actually found the problematic package. We are using rsbuild instead of vite for actually building the project and it looks like @rspack/binding-darwin-arm64 was somehow interfering. Updating this package to latest version seems to have fixed my issue.