Angular CLI application error: Cannot find name 'TreeNode'

UI Components for Angular
Post Reply
pzmarlicki
Posts: 16
Joined: 27 May 2013, 05:11

22 Feb 2017, 18:19

I have set up the PrimeNG CLI quickstart sample from https://github.com/primefaces/primeng-quickstart-cli. It's working beautifully.
Then I've added a tree component, following the instructions at http://www.primefaces.org/primeng/#/tree. Now, when I attempt to run ng serve, I get these messages:

ERROR in TreeNode is not an NgModule
ERROR in C:/REST/playground/play-web/ng/src/app/app.component.ts (77,12): Cannot find name 'TreeNode'.)
ERROR in C:/REST/playground/play-web/ng/src/app/app.module.ts (36,5): Cannot find name 'TreeNode'.)
webpack: Failed to compile.


Has anyone else encountered this problem?

Here is a list of all module versions I'm using:
+-- @angular/cli@1.0.0-beta.32.3
+-- @angular/common@2.4.8
+-- @angular/compiler@2.4.8
+-- @angular/core@2.4.8
+-- @angular/forms@2.4.8
+-- @angular/http@2.4.8
+-- @angular/platform-browser@2.4.8
+-- @angular/platform-browser-dynamic@2.4.8
+-- @angular/router@3.4.8
+-- @types/jasmine@2.5.43
+-- @types/node@6.0.63
+-- angular-in-memory-web-api@0.2.4
+-- codelyzer@1.0.0-beta.1
+-- core-js@2.4.1
+-- font-awesome@4.7.0
+-- jasmine-core@2.4.1
+-- jasmine-spec-reporter@2.5.0
+-- karma@1.2.0
+-- karma-chrome-launcher@2.0.0
+-- karma-cli@1.0.1
+-- karma-jasmine@1.1.0
+-- karma-remap-istanbul@0.2.2
+-- primeng@2.0.1
+-- protractor@4.0.9
+-- reflect-metadata@0.1.10
+-- rxjs@5.0.1
+-- ts-node@1.2.1
+-- tslint@3.13.0
+-- typescript@2.0.10
+-- webdriver-manager@10.2.5
`-- zone.js@0.7.7

stayingcool
Posts: 11
Joined: 06 Dec 2016, 07:50

25 Mar 2017, 12:42

I get the same error.

Initially it started with the below error [as seen in the browser console]:
Can't bind to 'value' since it isn't a known property of 'p-tree'.
1. If 'p-tree' is an Angular component and it has 'value' input, then verify that it is part of this module.
2. If 'p-tree' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.


I have imports statement for:
import { TreeNode } from 'primeng/primeng';

Strangely when I place TreeNode under
@NgModule({
imports: [BrowserModule,
FormsModule,
HttpModule,
TreeNode,
.
.
]

I see the following error from IDE Intellisense:
[ts] 'TreeNode' only refers to a type, but is being used as a value here.

Then I looked at this https://github.com/primefaces/primeng/issues/127 which is one year old and tried to import the TreeNode as follows in the app.module.ts. Still the issue is at large:
import { TreeNode } from 'primeng/components/common/api';

Wondering if you have moved past this issue? If so can you comment please?

pzmarlicki
Posts: 16
Joined: 27 May 2013, 05:11

27 Mar 2017, 01:11

Yes, I have resolved the issue by correcting the imports in my module:
  • Added "import { TreeModule, TreeNode } from 'primeng/primeng';"
  • Added "TreeModule" to the list of imports inside the annotation @NgModule
Pawel Zmarlicki
__________________________________________________
Angular 10; PrimeNG 10

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests