Angular 6包含Google闭包库

时间:2018-09-15 22:47:59

标签: angular typescript jasmine google-closure-compiler google-closure-library

我想在我的angular 6应用程序中包含google closure library。我已经申请

npm install google-closure-compilernpm install google-closure-library

该应用可以编译并运行。但是,当我尝试运行用ng test编写的测试时,它会显示错误消息:

ERROR in ./node_modules/google-closure-library/closure/goog/boostrap/nodejs.js
Module not found: Error: Can't resolve 'fs' in './node_modules/google-closure-library/closure/goog/bootstrap'

ERROR in ./node_modules/google-closure-library/closure/goog/promise/testsuiteadapter.js
Module not found: Error: Can't resolve 'promises_aplus_tests' in './node_modules/google-closure-library/closure/goog/promise/testsuiteadapter.js'

我使用有角度的官方demo示例,我刚刚添加了测试并安装了这两个库。我的猜测是我需要配置karma.conf.js,但是我不知道该怎么做,有人知道如何解决吗?

1 个答案:

答案 0 :(得分:1)

尝试将其添加到您的webpack配置中

node: {
  fs: 'empty'
}

您还可以看到它是如何实现的

https://github.com/angular/closure-demo