By Nahuel Olgiati


2016-09-15 15:03:03 8 Comments

I'm using [email protected] (webpack) and [email protected]

After create a fresh angular-cli project i made a few changes to add primeng:

1 on package.json:

"primeng": "^1.0.0-beta.15"

2 on angular-cli.json:

"styles": [ "styles.css", "../node_modules/primeng/resources/themes/omega/theme.css", "../node_modules/font-awesome/css/font-awesome.min.css", "../node_modules/primeng/resources/primeng.min.css" ],
"scripts": [ "../node_modules/primeng/primeng.js" ]

3 on app.module.ts:

@NgModule({ declarations: [ AppComponent ],
imports: [ BrowserModule, FormsModule, HttpModule, PanelModule ],
providers: [], bootstrap: [AppComponent] }) export class AppModule { }

Problem:

Uncaught ReferenceError: require is not defined Unexpected value 'undefined' imported by the module 'AppModule'

Any help to add primeng to angular-cli... will we great! :)

1 comments

@Brocco 2016-09-15 16:27:03

So just about everything you have there looks good.

The issue lies in that you're attempting to include primeng as a script tag (which is for global libraries like jQuery). But since primeng deploys modules you can simply import it in your module and then supply that to your NgModule like this:

import { ButtonModule } from 'primeng/components/button/button';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    ButtonModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

And then you'll also want to remove the reference to primeng.js from your angular-cli.json

@Nahuel Olgiati 2016-09-15 16:55:05

Thanks a lot Brocco, you've made my day!

Related Questions

Sponsored Content

9 Answered Questions

6 Answered Questions

[SOLVED] How to upgrade Angular 2 version in angular-cli project?

  • 2016-12-30 23:06:54
  • The Gilbert Arenas Dagger
  • 61230 View
  • 49 Score
  • 6 Answer
  • Tags:   angular angular-cli

1 Answered Questions

PrimeNg <component> is not a known element error (@angular-2.0.0 & primeng-1.0.0-beta.16)

  • 2016-09-19 20:22:36
  • user6850401
  • 7661 View
  • 17 Score
  • 1 Answer
  • Tags:   angular primeng

1 Answered Questions

[SOLVED] ERROR in Error: AppModule is not an NgModule - Angular-cli

1 Answered Questions

How to add third party libraries in Angular 4 using Webpack?

1 Answered Questions

[SOLVED] PrimeNg Error: Quill is not defined

2 Answered Questions

3 Answered Questions

3 Answered Questions

[SOLVED] [email protected] with primeng 404 issues

Sponsored Content