Closed stevermeister closed 7 years ago
That's very strange--I'll try setting up a project myself and seeing what happens
it looks like the CLI changed how they're handling packages in 1.2 so I think what's happening is that installing a 3rd party package installs the @angular/*
packages more than once as far as the CLI can tell
I ran npm install
inside myapp
and everything seemed to work after that
even after npm install
does not work for me :(
you're getting the same error?
just removed everything and did with npm install - and now it works, weird..
ok, now I got something else when try to include the module:
AngularSwitcheryModule is not an NgModule
Yeah I did too, try doing AngularSwitcheryModule.forRoot()
on the import
sorry, my bad, true
now something new:
ERROR in Error encountered resolving symbol values statically. Calling function 'AngularSwitcheryMo
dule', function calls are not supported. Consider replacing the function or lambda with a reference
to an exported function, resolving symbol AppModule in /Users/stevermeister/workspace/research/swt
tt/src/app/app.module.ts, resolving symbol AppModule in /Users/stevermeister/workspace/research/swt
tt/src/app/app.module.ts
Weird, I didnt get that. Can I see your app.module.ts
?
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AngularSwitcheryModule } from 'angular-switchery';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AngularSwitcheryModule.forRoot()
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
and the most weird thing: when I remove line
AngularSwitcheryModule.forRoot()
it works
and when I return it back (without stoping ng serve
) it works!!!!
BUT when I stop ng serve
and try to run it again - same error
Interesting...still looking into it
I'm not sure if this is looking like something the library is doing wrong...
This issue against the CLI has devs complaining of the same problem.
Yes, I also find this thread. Is there a way to reproduce it without publishing? Basically to run compiled version
Further investigation led to this answer by @trekhleb which led to this answer by @SebastianSchenk
So I'm not sure what to think...
So...that error doesn't have a big effect on running ng serve
after the initial pass.
Basically, as you said, @stevermeister, if you just save a file for a second time, it'll recompile no problem...this is a really odd problem.
Quick question, @stevermeister, what OS are you using?
macOS Sierra
all information about env is provided here - https://github.com/angular/angular-cli/issues/6961
Well there goes that theory 😢
Still trying to parse it out...
Just a "update":
I may have figured it out! I think its two-fold:
types
attribute in package.json
should be typings
./[your package].d.ts
not ./index.d.ts
So (and you can do this from within your Angular CLI app), modify the package.json
of your library so that the line:
"types": "./index.d.ts",
becomes:
"typings": "./angular-switchery.d.ts",
And let me know if that fixes anything...
I published my test library for Angular librarian with the changes and it seems to be working.
It also makes it so you don't have to do .forRoot()
, unless you need to.
@stevermeister, I'll leave this to you to close. You can do so by updating to the latest version, if need be.
@gonzofish it works! thank you very much! sorry for delay, did not have time to check and update the app.
Excellent! I'll merge it in when I finish up the testing branch I thought this was a different issue 😄
not sure whether it's a bug of angular-librarian, but decided to report it also here to let you know https://github.com/angular/angular-cli/issues/6961