我正在使用Angular2开发应用程序。我正在尝试导入和使用外部库'benchmark.js'。所以,我使用'npm i --save benchmark'来安装它。 package.json的依赖关系如下。
"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"
},
然后,我运行'npm install',如果我查看node_modules,就会有基准目录。但是当我尝试使用'基准'中的'import Suite'导入时,它会给我一个错误,例如'无法精确模块'基准测试'。我以为我可以从rxjs导入像Observable这样的Suite对象。我的应用方式与Observable完全相同。无论如何,我如何能够在我的组件中使用benchmark.js。