You just need to enable it to enable the moment using CommonJS syntax, not import. Try the following:
let moment = require('moment');
This is because the moment is not yet as an ES6 module, and as such will not work with the new import syntax.
UPDATE:
When I think about it, I used this approach only in my unit tests. Using it in your application may not work well, because this approach uses node require , which cannot be used on the client side.
However, when using Moment in your components, you can use angular2-moment . Full installation instructions can be found on the GitHub page, but usage is as follows:
<div>today is {{ Date.now() | amDateFormat:'LL' }}</div>
There are several other pipes you can use, all of which are documented on the GitHub page.
UPDATE 2:
Starting with version v2.10.0, Moment now supports ES6 syntax, so you can use any ES6 import syntax instead of require .
source share