簡體   English   中英

使用webpack加載node_modules

[英]load node_modules with webpack

我想加載一些模塊,例如:

  • 時刻
  • echarts

我的package.json:

  • “echarts”:“^ 3.1.10”
  • “時刻”:“^ 2.14.1”

但我有下一個錯誤:

VM2282:1未捕獲的ReferenceError:未定義時刻(...)

我的Webpack配置:

{ test: /\\.js$/, loader: 'babel', exclude: /node_modules/ }

我不知道發生了什么。 有誰能夠幫助我?

添加到vendor.ts:

import 'echarts';
import 'moment';

並從webpack配置中刪除您的代碼。 這適合我。

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)
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM