量角器E /启动器-错误:ReferenceError:未定义窗口

时间:2018-08-28 13:33:18

标签: protractor angular-cli ngx-bootstrap ng-packagr

我用angular-cli v6和ng-packagr创建了一个包含ngx-bootstrap 3.0.1作为peerDependency的角度库,我运行该应用程序没有问题,但是如果我启动量角器,则会出现以下错误:

I/launcher - Running 1 instances of WebDriver
I/direct - Using ChromeDriver directly...
DevTools listening on ws://127.0.0.1:12281/devtools/browser/e174b42c-8db0-494a-aba0-4366d555a98b
E/launcher - Error: ReferenceError: window is not defined
at Object. (\node_modules\ngx-bootstrap\bundles\webpack:ngx-bootstrap.umd\webpack\universalModuleDefinition:10:2)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at \dist\sg-ng-core-components\bundles\sg-ng-core-components.umd.js:2:268
at Object. (\dist\sg-ng-core-components\bundles\sg-ng-core-components.umd.js:5:2)

这是tsconfig.lib.ts:

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "outDir": "../../out-tsc/lib",
    "target": "es2015",
    "module": "es2015",
    "moduleResolution": "node",
    "declaration": true,
    "sourceMap": true,
    "inlineSources": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "types": [],
    "lib": [
      "dom",
      "es2015"
    ]
  },
  "angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "flatModuleId": "AUTOGENERATED",
    "flatModuleOutFile": "AUTOGENERATED"
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

这是tsconfig.e2e:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/e2e",
    "module": "commonjs",
    "target": "es2017",
    "types": [
      "jasmine",
      "node"
    ]
  }
}

这似乎是由于ngx-bootstrap.umd引起的,但它在e2e测试之外无法正常工作。有谁知道这是由于ng-packagr,量角器还是ngx-bootstrap造成的?

有人可以解释一下量角器如何在库的源代码中抛出错误(它可以与ng serve一起工作)?

预先感谢

0 个答案:

没有答案