2017-07-07 216 views
3

我面臨的問題:錯誤:TSError:⨯無法編譯打字稿

我的項目是建立在Angular4以打字稿,用量角器&因緣端對端測試。

特拉維斯-CI有此錯誤:

[03:34:54] E/launcher - Error: TSError: ⨯ Unable to compile TypeScript 
Cannot find type definition file for 'jasmine'. (2688) 
Cannot find type definition file for 'node'. (2688) 
e2e/app.e2e-spec.ts (1,32): Cannot find module './app.po'. (2307) 
e2e/app.e2e-spec.ts (4,1): Cannot find name 'describe'. (2304) 
e2e/app.e2e-spec.ts (7,3): Cannot find name 'beforeEach'. (2304) 
e2e/app.e2e-spec.ts (11,3): Cannot find name 'it'. (2304) 
e2e/app.e2e-spec.ts (13,5): Cannot find name 'expect'. (2304) 

The command "ng e2e" exited with 4. 

我tsconfig.json:

{ 
    "compileOnSave": false, 
    "compilerOptions": { 
    "outDir": "./dist/out-tsc", 
    "baseUrl": ".", 
    "paths": { 
     "*": ["./node_modules/*", "*"] 
    }, 
    "sourceMap": true, 
    "declaration": false, 
    "moduleResolution": "node", 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "target": "es5", 
    "types": [ "node", "jasmine" ], 
    "typeRoots": [ 
     "./node_modules/@types" 
    ], 
    "lib": [ 
     "es2016", 
     "dom" 
    ] 
    } 
} 

我tsconfig.spec.json:

{ 
    "compilerOptions": { 
    "sourceMap": true, 
    "declaration": false, 
    "moduleResolution": "node", 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "lib": [ 
     "es2016", 
     "dom" 
    ], 
    "outDir": "../out-tsc/spec", 
    "module": "commonjs", 
    "target": "es5", 
    "baseUrl": "", 
    "types": [ 
     "jasmine", 
     "node" 
    ], 
    "typeRoots": [ 
     "../node_modules/@types" 
    ] 
    }, 
    "files": [ 
    "test.ts" 
    ], 
    "include": [ 
    "**/*.spec.ts" 
    ] 
} 

節點v6.10.3

npm v3.10.10

請幫幫我。

+0

你可以參考的解決辦法給出[這裏](https://github.com/AngularClass/angular-starter/issues/615)。不知道這些是否相同。乾杯! – demouser123

+0

我更新我的devDependencies並修復這個錯誤! – RicoLiu

回答

2

我遇到了同樣的問題。首先,我從package.json中刪除ts-node和typescript。然後,

npm install ts-node --save-de 
npm install -g typescript --save-dev