Natasha
Natasha

Reputation: 21

Angular PrimeNG Menu error "Module not found"

I have tried all solutions in this thread, but still can't figure this out.

I am trying to use PrimeNG Menu.

In app.module.ts imported MenubarModule: import { MenubarModule } from 'primeng/menubar';

In app.component.ts imported MenuItem and so on as per PrimeNG instructions.

Yet while compiling i am getting an error for app.component.ts:

"Module not found: Error: Can't resolve 'primeng/menubar/menubar'"



Package.json:

{
  "name": "gportal",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~10.0.14",
    "@angular/common": "~10.0.14",
    "@angular/compiler": "~10.0.14",
    "@angular/core": "~10.0.14",
    "@angular/forms": "~10.0.14",
    "@angular/platform-browser": "~10.0.14",
    "@angular/platform-browser-dynamic": "~10.0.14",
    "@angular/router": "~10.0.14",
    "angular-auth-oidc-client": "^11.2.0",
    "primeflex": "^2.0.0",
    "primeicons": "^4.0.0",
    "primeng": "^10.0.0-rc.3",
    "rxjs": "~6.5.5",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1000.8",
    "@angular-devkit/build-ng-packagr": "~0.1000.8",
    "@angular/cli": "~10.0.8",
    "@angular/compiler-cli": "~10.0.14",
    "@types/node": "^12.11.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "ng-packagr": "^10.0.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.9.5"
  }
}

Upvotes: 2

Views: 6384

Answers (1)

Pardeep Jain
Pardeep Jain

Reputation: 86790

I believe you are using the latest version of Primeng/Angular. So your imports should look like -

import {MenuItem} from 'primeng/api';

You don't need to import Menubar, For more information check out here - https://primefaces.org/primeng/showcase/#/menubar

PS: Here you can compare your code with the code which is working (Stackblitz Example)

Upvotes: 0

Related Questions