2017-09-22 4 views
0

J'espérais utiliser le ng4-material-dropdown et j'ai installé le paquet en appelant le npm install ng4-material-dropdown --save depuis le dossier racine de mon projet. Bien que je puisse confirmer que ce dossier existe à l'intérieur de /node-components, l'importer dans mon app.module.ts génère une erreur.Angular 4 Erreur lors du chargement du composant

importation
import { Ng4DropdownModule } from 'ng4-material-dropdown';

Erreur

Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/ng4-material-dropdown patchProperty/desc.set/[email protected]http://localhost:3000/node_modules/zone.js/dist/zone.js:1055:30 [email protected]http://localhost:3000/node_modules/zone.js/dist/zone.js:424:17 [email protected]http://localhost:3000/node_modules/zone.js/dist/zone.js:191:28 ZoneTask/[email protected]http://localhost:3000/node_modules/zone.js/dist/zone.js:486:28 Error loading http://localhost:3000/ng4-material-dropdown as "ng4-material-dropdown" from http://localhost:3000/app/app.module.js Stack trace: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/ng4-material-dropdown patchProperty/desc.set/[email protected]http://localhost:3000/node_modules/zone.js/dist/zone.js:1055:30 [email protected]http://localhost:3000/node_modules/zone.js/dist/zone.js:424:17 [email protected]http://localhost:3000/node_modules/zone.js/dist/zone.js:191:28 ZoneTask/[email protected]http://localhost:3000/node_modules/zone.js/dist/zone.js:486:28 Error loading http://localhost:3000/ng4-material-dropdown as "ng4-material-dropdown" from http://localhost:3000/app/app.module.js

Ceci est probablement une erreur très rooky, mais je ne peux pas pour la vie de me comprendre cela.

Répondre

0

Si vous avez généré l'application avec le cli angulaire, vous devriez avoir un angular.cli.json. Il a une liste de scripts de vendeurs externes à empaqueter. Son imbriqué dans apps.scripts. Essayez d'ajouter quelque chose comme ceci:

{ 
    //stuff 
    "apps": [ 
    { 
     //Here it is 
     "scripts": [ 
     "ng4-material-dropdown" 
     ] 
    } 
    ], 
    //more stuff 
} 
+2

Il utilise 'Erreur: (SystemJS) Erreur XHR (404 Not Found)' – yurzui

+0

Hélas, je jamais utilisé le cli angulaire. J'ai revérifié juste pour être sûr, mais ce fichier n'existe pas pour moi. – Senshi

+0

Bon appel yurzui, avez-vous un systemjs.config.js Senshi? – bgraham