Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Uncaught Error: Unexpected value 'ArithmeticModule' imported by the module 'AppModule'. Please add a @NgModule annotation #15

Closed
jjlgjkkl opened this issue Jun 29, 2017 · 6 comments

Comments

@jjlgjkkl
Copy link

jjlgjkkl commented Jun 29, 2017

In angular4.2.4, getting this error
when running npm start (ng server), the building process is ok, but getting this error in the browser
my app.module.ts
import {ArithmeticModule} from 'angular-library-starter';
@NgModule({
declarations: [
AppComponent, HelloComponent
],
imports: [
BrowserModule, routing, ArithmeticModule.forRoot()
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

error stack from browser
Uncaught Error: Unexpected value 'ArithmeticModule' imported by the module 'AppModule'. Please add a @NgModule annotation.
at syntaxError (http://localhost:4200/vendor.bundle.js:19702:34)
at http://localhost:4200/vendor.bundle.js:33386:44
at Array.forEach (native)
at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver.getNgModuleMetadata (http://localhost:4200/vendor.bundle.js:33369:49)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler.loadModules (http://localhost:4200/vendor.bundle.js:44692:70)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler.compileModuleAndComponents (http://localhost:4200/vendor.bundle.js:44665:36)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler.compileModuleAsync (http://localhost:4200/vendor.bundle.js:44594:37)
at PlatformRef
.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef
.bootstrapModuleWithZone (http://localhost:4200/vendor.bundle.js:50335:25)
at PlatformRef
.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_.bootstrapModule (http://localhost:4200/vendor.bundle.js:50321:21)
at Object.../../../../../src/main.ts (http://localhost:4200/main.bundle.js:17877:124)

@robisim74
Copy link
Owner

robisim74 commented Jun 29, 2017

Maybe you got something wrong with the versions: angular/angular#15763

@jjlgjkkl
Copy link
Author

jjlgjkkl commented Jun 30, 2017

I really appreciate for your reply.
I checked and tried, still the same exception.
I only simplely download your code and then run "ng run build".
Then, using angular cli 1.1.0 ,"ng new" a new project, and then execute "npm i d:\angular-library-starter-master\dist".
Next ,executting "npm start", the error occurs in the browsser. but the build process is ok.
If executting in aot mode(ng serve --aot),everything goes OK.

@robisim74
Copy link
Owner

ng run build, npm i d:\angular-library-starter-master\dist: where did you find those commands? Please follow the instructions in the README on how to use this starter. Greetings

@jjlgjkkl
Copy link
Author

thank you very much!!!
wow, it's OK now.
but , i still have no idea what's the difference between npm i d:\angular-library-starter-master\dist and d:\angular-library-starter-master.tgz
but ,whatever
thank you again!

@antlaij
Copy link

antlaij commented Jul 3, 2017

Hi @robisim74 ,
I am having the same problem.
After I did npm i d:\angular-library-starter-master\dist
It works. Thank you
I have also try using npm link to add the dist folder to my project.
I have got the same error again.
Can you tell me what it the different between npm install and npm link?
Thanks

@robisim74
Copy link
Owner

@antlaij about npm link see this issue: #2 To use it with webpack, you need to change the configuration of webpack, and with Angular-cli for example you can not do it.
Using npm pack, instead, you simulate the real installation.
Greetings

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

No branches or pull requests

3 participants