Error: TSError: ⨯ Unable to compile TypeScript
Hey guys, I am facing the problem:
My Project is built on Angular4 with typescript
Node v6.10.3
npm v3.10.10
Travis-CI has this error:
run ng e2e,
log:
[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.
My 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"
]
}
}
Any idea about the problem?
It's happened also to me in a personal project https://github.com/Ks89/angular-webpack-skeleton/issues/32 and it's related to https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14569
To fix that, I downgraded "@types/jasmine": "2.5.45" to "@types/jasmine": "=2.5.38"
@Ks89 I downgraded "@types/jasmine":"=2.5.38"
But it is not work, Travis-ci also has this error
here is my package.json:
{
"name": "angular-src",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.0.3",
"@angular/common": "^4.0.3",
"@angular/compiler": "^4.1.3",
"@angular/compiler-cli": "^4.0.3",
"@angular/core": "^4.1.3",
"@angular/forms": "^4.0.3",
"@angular/http": "^4.0.3",
"@angular/platform-browser": "^4.0.3",
"@angular/platform-browser-dynamic": "^4.0.3",
"@angular/platform-server": "^4.0.3",
"@angular/router": "^4.0.3",
"@types/jasminewd2": "^2.0.2",
"angular2-flash-messages": "^1.0.8",
"angular2-jwt": "^0.2.0",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.9"
},
"devDependencies": {
"@angular/cli": "^1.0.1",
"@angular/compiler-cli": "^4.1.3",
"@types/jasmine": "=2.5.38",
"@types/node": "~7.0.5",
"codelyzer": "~2.0.0",
"jasmine": "^2.6.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"mocha": "^3.4.2",
"protractor": "~5.1.0",
"ts-node": "~2.1.0",
"tslint": "~4.5.0",
"typescript": "^2.3.3"
}
}
I don't know. My project is working with this trick. Did you try to remove node_modules and package-lock.json only to be sure that you are using the right dependency?
@Ks89 Thank you! I update my devDependencies and fix this error!
What dev dependencies did you update?
@rcw0086
"engines": {
"node": "6.11.1"
}
here is my devDependencies
"devDependencies": {
"@angular/cli": "^1.0.1",
"@angular/compiler-cli": "^4.2.6",
"@types/jasmine": "=2.5.38",
"@types/node": "^8.0.10",
"codelyzer": "~2.0.0",
"jasmine": "^2.6.0",
"jasmine-core": "~2.6.4",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"mocha": "^3.4.2",
"protractor": "~5.1.2",
"ts-node": "^3.2.0",
"tslint": "~4.5.0",
"typescript": "=2.3.2"
}
Thanks! I was able to resolve by updating @types/*
Updating "@types/jasmine": "=2.5.38" solved that issue for me.
downgrading "jasmine-core" from "2.7.0" to "2.6.2" fixed my issue my devDeps
"devDependencies": {
"@angular/cli": "^1.3.1",
"@angular/compiler-cli": "^4.3.5",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/moment-timezone": "^0.2.34",
"@types/node": "^8.0.24",
"codelyzer": "~3.1.2",
"cross-env": "^5.0.5",
"jasmine-core": "2.6.2",
"jasmine-spec-reporter": "4.2.1",
"jquery": "^3.2.1",
"karma": "1.7.0",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^1.0.1",
"karma-coverage-istanbul-reporter": "^1.3.0",
"karma-jasmine": "^1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"semantic-ui-calendar": "0.0.8",
"semantic-ui-css": "^2.2.12",
"ts-node": "3.3.0",
"tslint": "^5.6.0",
"typescript": "~2.4.2",
"webpack": "3.8.1"
}
Mine is not a new project, I am running an angular2 project with "@angular/cli": "1.2.0". I updated my typescript version from 2.0.3 to 2.7.2 and now I am getting similar issues while running ng e2e. I have updated all the @types/* to latest versions, also updated jasmine-core but still have the same issue. Does anyone know any other solution to this?
EDIT:
I fixed it by updating ts-node to 5.0.1. Versions above this were giving errors like the one below while running ng e2e:
Experimental support for decorators i......
Apart from the above change, I also changed few lines in protractor.conf.js
Changed:
beforeLaunch: function () {
require('ts-node').register({
project: 'e2e'
});
},
to
beforeLaunch: function () {
require('ts-node/register')
}
Please note: I only had to do the above changes, I didn't upgrade
@types/*orjasmine-core
I had this issue just in travis enviroment and changin to 2.5.38 worked!
https://travis-ci.org/mariohmol/ng-gantt/builds/459888259
I also faced the same issue, find the error below

Solution: Check the tsconfig.json and set "allowJs": false