How to use external library 'benchmark.js' in Angular2?

485 views Asked by At

I am developing application using Angular2. I am trying to import and use external library 'benchmark.js'. So, I install it using 'npm i --save benchmark'. The dependencies of package.json is like following.

 "name": "angular2-webpack",
  "version": "1.0.0",
  "description": "A webpack starter for Angular",
  "scripts": {
    "start": "webpack-dev-server --inline --progress --port 8080",
    "test": "karma start",
    "build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail"
  },
  "license": "MIT",
  "dependencies": {
    "@angular/common": "~2.3.0",
    "@angular/compiler": "~2.3.0",
    "@angular/core": "~2.3.0",
    "@angular/forms": "~2.3.0",
    "@angular/http": "~2.3.0",
    "@angular/platform-browser": "~2.3.0",
    "@angular/platform-browser-dynamic": "~2.3.0",
    "@angular/router": "~3.3.0",
    "benchmark": "^2.1.3",
    "core-js": "^2.4.1",
    "reflect-metadata": "^0.1.8",
    "rxjs": "5.0.0-rc.4",
    "systemjs": "0.19.40",
    "zone.js": "^0.7.2"
  },

And then, I run 'npm install', if I look at the node_modules, there is benchmark directory. But when I tried to import using 'import Suite from 'benchmark'', it gives me error like 'Cannot fine module 'benchmark'. I thought I can import the Suite object like Observable from rxjs. I applied the exactly same way I did for Observable. Anyway, how I am able to use benchmark.js in my component.

0

There are 0 answers