Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vite-plugin-angular throws error #1458

Open
1 of 2 tasks
joewIST opened this issue Nov 25, 2024 · 4 comments
Open
1 of 2 tasks

vite-plugin-angular throws error #1458

joewIST opened this issue Nov 25, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@joewIST
Copy link

joewIST commented Nov 25, 2024

Please provide the environment you discovered this bug in.

@analogjs/vite-plugin-angular : 1.9.4

Which area/package is the issue in?

vite-plugin-angular

Description

I am using the vite-plugin-angular to get my unit tests to work. I have been getting errors such as "Expected to be running in 'ProxyZone', but it was not found." and decided to investigate the plugin to overcome these. Now the ProxyZone errors are gone but now there is an issue with "@angular/build/private".

Please provide the exception or error you saw

Cannot find module '@angular/build/private'
Require stack:
- C:\Users\joe.williams\Projects\Megatron\frontend\src\node_modules\@analogjs\vite-plugin-angular\src\lib\utils\devkit.js
Error: Cannot find module '@angular/build/private'
Require stack:
- C:\Users\joe.williams\Projects\Megatron\frontend\src\node_modules\@analogjs\vite-plugin-angular\src\lib\utils\devkit.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Module._resolveFilename (C:\Users\joe.williams\Projects\Megatron\frontend\src\node_modules\tsconfig-paths\lib\register.js:103:40)
    at Module._load (node:internal/modules/cjs/loader:986:27)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at file:///C:/Users/joe.williams/Projects/Megatron/frontend/src/node_modules/@analogjs/vite-plugin-angular/src/lib/utils/devkit.js:37:87
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async loadConfigFromBundledFile (file:///C:/Users/joe.williams/Projects/Megatron/frontend/src/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:66691:15)
    at async loadConfigFromFile (file:///C:/Users/joe.williams/Projects/Megatron/frontend/src/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:66532:24)

Other information

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@joewIST joewIST added the bug Something isn't working label Nov 25, 2024
@AlexAegis
Copy link

AlexAegis commented Nov 25, 2024

You likely have direct imports from vitest like this: import { describe, it } from 'vitest';

angular tests require patched test hooks (it, describe etc) and when importing them from vitest you get the raw, unpatched ones. You must only use the global, patched functions provided by analog

@joewIST
Copy link
Author

joewIST commented Nov 25, 2024

Hi @AlexAegis thanks for your response. I have only just installed vitest in our project (we were previously using Jest) so there are no imports from vitest that could be causing this. This error seems to be more to do with accessing a directory that doesn't exist...

@brandonroberts
Copy link
Member

@joewIST what package manager are you using? The @analogjs/vite-plugin-angular package has peer dependencies, including @angular/build that should be handled by most package managers, with yarn being an exception.

@joewIST
Copy link
Author

joewIST commented Nov 26, 2024

Thanks @brandonroberts. That would explain it; we use Yarn. Is there a workaround for use with Yarn or is this just not supported yet? I couldn't see anything on the documentation but I may have missed something!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants