Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Error: [$injector:unpr] Unknown provider: i with Vite #26

@MetaMmodern

Description

@MetaMmodern

Hi, I've been trying to upgrade our internal company project to match your template, everything went almost fine until I tried to make a build and serve it through vite serve. It gave me this error:
image
I understand that this happens because of minification by Vite, but there are 2 troubles:

  1. If I disable minification in Vite Config it still ads digits to places where we have similar providers in use (for example we use NavigationService in 2 components thus Vite will name second entry as NavigationService2 and it will break DI again).

image

  1. I could not find any piece of code in your repo which would help me fix this, because your cloned local project builds just okay without errors.

Since it's private repo I can't show code.(Moreover, I won't be able to create a Sandbox it will take a lot more time to do, so sorry).
But one important detail is that I kept my controllers, services and directives as function and did not convert them into ES6 classes.
Main question is: how to tell vite to make everything fine?

  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Providers are set correctly.

Current Behavior

Messes up providers during build with minification.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfyiSome good-to-know insights preserved as living docshelp wantedExtra attention is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions