4

我想使用protractor.jsv5.x在我的 Angular项目中实现 e2e 。但是当我运行命令时

ng e2e -s false

我在下面收到此错误,谁能告诉我如何解决此问题?

[15:58:11] E/launcher - Error: TSError: ⨯ Unable to compile TypeScript
The 'files' list in config file 'tsconfig.json' is empty. (18002)
    at load (F:\Commutatus\yop-v3\node_modules\ts-node\src\index.ts:159:13)
    at service (F:\Commutatus\yop-v3\node_modules\ts-node\src\index.ts:285:32)
    at shouldIgnore (F:\Commutatus\yop-v3\node_modules\ts-node\src\index.ts:293:21)
    at Object.require.extensions.(anonymous function) [as .ts] (F:\Commutatus\yop-v3\node_modules\ts-node\src\index.ts:302:11)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at F:\Commutatus\yop-v3\node_modules\protractor\node_modules\jasmine\lib\jasmine.js:84:5
[15:58:11] E/launcher - Process exited with error code 100

这是我的tsconfig.json(位于e2e文件夹内)-

{
  "compileOnSave": false,
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc-e2e",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types"
    ]
  }
}
4

2 回答 2

1

使用“文件”属性。希望它可以帮助你。

{
    "compilerOptions": {
        "module": "commonjs",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "sourceMap": true
    },
    "files": [
        "core.ts",
        "sys.ts",
        "types.ts",
        "scanner.ts",
        "parser.ts",
        "utilities.ts",
        "binder.ts",
        "checker.ts",
        "emitter.ts",
        "program.ts",
        "commandLineParser.ts",
        "tsc.ts",
        "diagnosticInformationMap.generated.ts"
    ]
}
于 2019-01-07T12:14:41.457 回答
1

参考GitHub 上的这个问题,我已经找到了解决方案。问题出在ts-node版本上。我的版本是1.2.x并且为了ng e2e -s false工作它需要一个v5.0.1.

版本>v5.0.1也抛出同样的错误。

注意:- 我没有更新任何其他文件或依赖项

感谢@ashish701ranjan解决方案

于 2019-01-16T07:51:14.263 回答