I want to load some modules, for instance:
My package.json:
but I have the next errors:
VM2282:1 Uncaught ReferenceError: moment is not defined(…)
My Webpack config:
{ test: /\\.js$/, loader: 'babel', exclude: /node_modules/ }
I do not know what happend. Can anybody help me?
Add to vendor.ts:
import 'echarts';
import 'moment';
and remove your code from webpack config. This works for me.
import { Component } from '@angular/core';
import * as moment from 'moment';
import '../../public/css/styles.css';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor(){
let now = moment().format('LLLL');
console.log(now)
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.