-
Notifications
You must be signed in to change notification settings - Fork 38
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
No provider for Router! Angular CLI 1.3.2 #25
Comments
Hey Chris that's strange, is it a completely untouched CLI project ? I'll have to give this a shot, not sure why that would come up. |
Hi Mark Thank you for replying so quickly. Yes it's completely untouched. I noticed it after upgrading a large project and have now managed to get it working by pinning to an older version of angular (4.3.1). I'm using npm 5.3.0 if that matters. Going to try upgrading to latest now. |
I'm also seeing this after upgrading from angular 4.3.5 to 4.4.0-RC.0. It feels like it has something to do with one or both of these versioning oddities in my package-lock.json The first is that
The second is that
@chrisfoster78 can you check your |
I just tried the following combinations:
It looks like any time And then since All that being said, I don't know what the best path forward is. |
I figured out the resolution question. I basically just needed to learn Even though angular 4.4.0-RC.0 is listed as the latest, from So now the question becomes what's the correct way for PS. Sorry for the comment spam. I feel thinking I'm going to go to bed but then end up investigating further :) |
@dfederm Not a problem David, thanks for the research! I believe we need to set it as a peerDependency as opposed to a regular one, and that may solve the issue. Or we might need an OR for the version ^4.0.0 || 4.4.0-rc.0, rc0 might have been accidentally pushed out publically, since only full versions should be available, that should really only of been there if you installed via @next. Bizarre! |
You're right, it does seem weird that a prerelease would be marked as @latest. Here are some examples of what other libraries I use happen to be doing, sorted by how popular the library is (assuming that popular libs do it "the right way"):
So at least based on what other libs are doing, it looks like using a peerDependency as you mentioned is the most common pattern. |
@chrisfoster78 Published version 2.3.2 to npm thanks to @dfederm give it a shot! |
@MarkPieszak, @dfederm Thanks for your time and sorry I've not been much help. I've just tried another new project and got the following error:
I then tried adding I also observed the same dependency on @angular/router 4.3.6 in the package.lock file as @dfederm. But I don't think I was able to get version 2.3.1 working with angular 4.3.6, although could be mistaken. |
It seems like I have been getting this error in my bare bones project as I simply followed the minimal instructions for setting up and had not added any routes. Everything is fine after adding some routes and more importantly the dependency on the RouterModule. The latest version is missing the typings dependency for applicationinsights from my previous comment. Thanks for your help Chris |
Yes I think we need the types dependency and such back in peers, applicationinsights-js as well. |
I think you're right about the types, but it feels weird to have types as a dependency. Regarding the Router, which seems like a separate issue than these dependency issues, perhaps the Router should be marked as optional in the service's ctor? Just in case the app isn't using routing I guess. Probably rare in practice, but a little more generic. |
Published 2.3.3 to at least fix the typing issue, thank you guys for noticing these things! Apologies 👍 |
Published 2.3.4 and tried, the types dep error is gone, and I didn't see "No provider for Router" so I think we're all set now! |
I have just created a new empty project using the current Angular CLI (1.3.2) and the current angular-application-insights (2.3.1) and get a "No provider for Router!" error.
npm list --depth=0
package.json
The text was updated successfully, but these errors were encountered: