d3v5 Angular 8生产模式-错误TypeError :(无效0)不是函数 [英] d3v5 Angular 8 production mode - ERROR TypeError: (void 0) is not a function

查看:257
本文介绍了d3v5 Angular 8生产模式-错误TypeError :(无效0)不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

D3v5函数在开发模式下工作正常,但在生产模式下抛出运行时错误

D3v5 functions work fine in development mode but throwing run time errors in production mode

错误TypeError :(无效0)不是函数

ERROR TypeError: (void 0) is not a function

键入脚本代码

import { Component } from '@angular/core';
import {timeFormat} from 'd3-time-format';
...
export class AppComponent {

  constructor(){
    var formatTime = timeFormat("%B %d, %Y");
   console.log('Time parser :: ', formatTime(new Date))
  }
}

Package.json

Package.json

  "dependencies": {
    "@angular/animations": "~8.1.1",
    "@angular/common": "~8.1.1",
    "@angular/compiler": "~8.1.1",
    "@angular/core": "~8.1.1",
    "@angular/forms": "~8.1.1",
    "@angular/platform-browser": "~8.1.1",
    "@angular/platform-browser-dynamic": "~8.1.1",
    "@angular/router": "~8.1.1",
    "@types/d3": "^5.7.2",
    "d3": "^5.13.1",
    "rxjs": "~6.4.0",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  },

tsconfig.json-还尝试按照更新目标升级到Angular 8后d3.js中的错误

tsconfig.json - Also tried updating the target as per Error in d3.js after upgrading to Angular 8

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    **"target": "es5",**
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": ..
  },
  "angularCompilerOptions": ..
}

任何建议或线索将不胜感激.

Any suggestion or leads will be much appreciated.

谢谢

推荐答案

对于遇到类似问题的任何人,我都可以通过将d3撞到以下版本上来使它工作

For anyone encountering similar issue I was able to make it work by bumping d3 and angular to the below versions

 "dependencies": {
    "@angular/animations": "~8.2.14",
    "@angular/common": "~8.2.14",
    "@angular/compiler": "~8.2.14",
    "@angular/core": "~8.2.14",
    "@angular/forms": "~8.2.14",
    "@angular/platform-browser": "~8.2.14",
    "@angular/platform-browser-dynamic": "~8.2.14",
    "@angular/router": "~8.2.14",
    "@types/d3": "^5.7.2",
    "d3": "^5.14.0",
    "rxjs": "~6.4.0",
    "tslib": "^1.10.0",
    "zone.js": "~0.9.1"
  },

这篇关于d3v5 Angular 8生产模式-错误TypeError :(无效0)不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆