Skip to content
This repository was archived by the owner on Dec 17, 2018. It is now read-only.

ng serve command is broken after installing package created by angular-librarian #51

Closed
stevermeister opened this issue Jul 13, 2017 · 27 comments
Assignees

Comments

@stevermeister
Copy link

not sure whether it's a bug of angular-librarian, but decided to report it also here to let you know
angular/angular-cli#6961

@gonzofish
Copy link
Owner

That's very strange--I'll try setting up a project myself and seeing what happens

@gonzofish gonzofish self-assigned this Jul 13, 2017
@gonzofish
Copy link
Owner

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

@gonzofish
Copy link
Owner

I ran npm install inside myapp and everything seemed to work after that

@stevermeister
Copy link
Author

even after npm install does not work for me :(

@gonzofish
Copy link
Owner

you're getting the same error?

@stevermeister
Copy link
Author

just removed everything and did with npm install - and now it works, weird..

@stevermeister
Copy link
Author

ok, now I got something else when try to include the module:

AngularSwitcheryModule is not an NgModule

@gonzofish
Copy link
Owner

Yeah I did too, try doing AngularSwitcheryModule.forRoot() on the import

@stevermeister
Copy link
Author

sorry, my bad, true

@stevermeister
Copy link
Author

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

@gonzofish
Copy link
Owner

Weird, I didnt get that. Can I see your app.module.ts?

@stevermeister
Copy link
Author

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 { }

@stevermeister
Copy link
Author

stevermeister commented Jul 13, 2017

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

@gonzofish
Copy link
Owner

Interesting...still looking into it

@gonzofish
Copy link
Owner

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.

@stevermeister
Copy link
Author

Yes, I also find this thread.
Is there a way to reproduce it without publishing? Basically to run compiled version

@gonzofish
Copy link
Owner

Further investigation led to this answer by @trekhleb which led to this answer by @SebastianSchenk

So I'm not sure what to think...

@gonzofish
Copy link
Owner

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.

@gonzofish
Copy link
Owner

Quick question, @stevermeister, what OS are you using?

@stevermeister
Copy link
Author

macOS Sierra

all information about env is provided here - angular/angular-cli#6961

@gonzofish
Copy link
Owner

Well there goes that theory 😢

Still trying to parse it out...

@gonzofish
Copy link
Owner

Just a "update":

  1. I've seen answers from Angular team members saying to others that the metadata isn't being provided or its bad--but from any comparison I do (such as to the Angular Material outputs), everything looks correct.
  2. I'm really down in the weeds on the CLI trying to figure this out, I'm looking at the spot where the compiler tries to gather info about our module.
  3. This feels a bit insane to be doing.

@gonzofish
Copy link
Owner

I may have figured it out! I think its two-fold:

  1. The types attribute in package.json should be typings
  2. The value for that attribute should be ./[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...

@gonzofish
Copy link
Owner

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.

@gonzofish gonzofish added the bug label Jul 14, 2017
@gonzofish
Copy link
Owner

@stevermeister, I'll leave this to you to close. You can do so by updating to the latest version, if need be.

Link to latest release

@stevermeister
Copy link
Author

@gonzofish
it works!
thank you very much!
sorry for delay, did not have time to check and update the app.

@gonzofish
Copy link
Owner

gonzofish commented Aug 1, 2017

Excellent! I'll merge it in when I finish up the testing branch I thought this was a different issue 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants