DEV Community

Dushyant Pathak
Dushyant Pathak

Posted on

4 2

PrimeNG setup

PrimeNG is a UI library for Angular. It has a list of components that we can use in our Angular applications.

A lot of devies get this error when they try to add PrimeNG:

p-card is not a known Angular component
Enter fullscreen mode Exit fullscreen mode

Note here, that p-card is just an example, and the error could be for any PrimeNG component one might be using. To solve that, make sure you have followed ALL the following steps:

  • Installing the packages.
npm install primeng --save
npm install primeicons --save
Enter fullscreen mode Exit fullscreen mode

Make sure the following dependencies are added in the package.json file:


"dependencies": {
  //...
  "primeng": "^8.0.0",
  "primeicons": "^2.0.0"
},
Enter fullscreen mode Exit fullscreen mode
  • Import the necessary modules in the app.module.ts file.
import {CardModule} from 'primeng/card';   
import {MenuItem} from 'primeng/api'; 
Enter fullscreen mode Exit fullscreen mode

In the imports below, add the corresponding module.

imports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule,
Enter fullscreen mode Exit fullscreen mode
  • If you still get the same error, add this to the angular.json file, in the styles:
"styles": [
  "node_modules/primeicons/primeicons.css",
  "node_modules/primeng/resources/themes/nova-light/theme.css",
  "node_modules/primeng/resources/primeng.min.css",
  //...
],
Enter fullscreen mode Exit fullscreen mode

This should do the job!

Cheers! Happy coding!

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay