Reputation: 592
I am trying to install moment.
After npm install moment --save
, I import moment in my component, but when reload the page, I got 404 error: http://localhost:3000/moment
here is my component file import code:
import {Input, Output, Component} from "angular2/core"
import {TicketService} from "../services/ticket.service"
import {Ticket} from "./ticket";
import {OnInit} from "angular2/core";
import {Router, RouteParams, RouterLink, ROUTER_DIRECTIVES} from "angular2/router";
import * as moment from 'moment';
I don't understand why. Could someone help me on that ?
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/boot')
.then(null, console.error.bind(console));
</script>
Upvotes: 3
Views: 380
Reputation: 40657
You should map that 'moment' path to something under your system config. So it will know where to go.
System.config({
map:{
'moment': './node_modules/moment/moment'
},
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
The exact path may vary depending on your architecture of course.
Upvotes: 1