typescript - NG2 Tree module not found after install on an Angular 2 new app -


i have install ng2-tree plugin in new angular 2 app (rc4), after following this. plugin has been installed, , on node_modules folder.

i have tried use in component:

import {component} '@angular/core'; import {treemodel, treecomponent} "ng2-tree";  @component({     selector: 'tree-side',     templateurl: '../../pages/tree-side.html',     directives: [treecomponent]  }) export class treesidecomponent{     private tree: treemodel = {         value: 'programming languages programming paradigm',         children: [             {                 value: 'object-oriented programming',                 children: [                     {value: 'java'},                     {value: 'c++'},                     {value: 'c#'}                 ]             },             {                 value: 'prototype-based programming',                 children: [                     {value: 'javascript'},                     {value: 'coffeescript'},                     {value: 'lua'}                 ]             }         ]     }; } 

but error on npm console:

404 /ng2-tree 

i have modified system.config.js following code, trying find workaround:

var map = {    ...     'ng2-tree':                   'node_modules/ng2-tree' }; // packages tells system loader how load when no filename and/or no extension var packages = {     ...     'ng2-tree':                   { defaultextension: 'js' }, }; 

but error after:

error loading http://localhost:3000/node_modules/ng2-tree "ng2-tree" http://localhost:3000/app/pages/tree.component.js 

following instruction of thierry templier tried other configuration. including configuration lodash plugin, cause had same problem ng-tree after fixing ng-tree dependency.

 var map = { ...         'ng2-tree':                   'node_modules/ng2-tree',         'lodash':                   'node_modules/lodash'     };     // packages tells system loader how load when no filename and/or no extension     var packages = { ...         'ng2-tree':                   { main: 'index.js', defaultextension: 'js' },         'lodash':                   { main: 'index.js', defaultextension: 'js' }     }; 

but in case got:

[1] 16.08.08 12:04:09 404 /tree.component.html [1] 16.08.08 12:04:09 404 /node-menu.component.html  failed load tree.component.html ; zone: angular ; task: promise.then ; value: failed load tree.component.html 

apparently due relative path resolution, in anycase not correspond question.

i think missed main property in packages configuration ng2-tree:

var packages = {   ...   'ng2-tree': { main: 'index.js', defaultextension: 'js' }, }; 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -