Error: TSError: ⨯ Unable to compile TypeScript

前端 未结 5 1027
借酒劲吻你
借酒劲吻你 2021-02-05 08:44

I am facing the problem:

My Project is built on Angular4 with typescript, e2e testing with protractor & karma.

Travis-ci has this error:

相关标签:
5条回答
  • 2021-02-05 08:50

    I came here looking for a solution for a similar error when I updated my typescript version, Mine was 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 then I was getting similar issues like below while running ng e2e.

    Error: TSError: ⨯ Unable to compile TypeScript
    Cannot find type definition file for 'core-js'. (2688)
    Cannot find type definition file for 'grecaptcha'. (2688)
    Cannot find type definition file for 'jasmine'. (2688)
    Cannot find type definition file for 'moment-timezone'. (2688)
    Cannot find type definition file for 'node'. (2688)
    Cannot find type definition file for 'q'. (2688)

    The proposed solutions in this post didn't work for me.

    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 even though I had experimentalDecorators set to true in tsconfig.json:

    error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning

    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')
    }
    

    This is for people who may stumble into this post and the proposed solution doesn't work for them.

    0 讨论(0)
  • 2021-02-05 08:55

    if only the "npm install -g typescript" doesn't work.

    try to do "tsc" in the project folder

    0 讨论(0)
  • 2021-02-05 09:05

    I also faced the same issue, find the error has been attached

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

    0 讨论(0)
  • 2021-02-05 09:10

    I had met same issue. First I remove ts-node and typescript from package.json. then,

    npm install ts-node --save-dev
    npm install typescript -g 
    npm install typescript --save-dev
    
    0 讨论(0)
  • 2021-02-05 09:10

    This is my solution for this issue: - Run this command

    npm install -save-dev typescript@2.3.4

    npm WARN code_gui@0.0.1 No repository field.
    npm WARN code_gui@0.0.1 No license field.
    
    + typescript@2.3.4
    updated 1 package and audited 657 packages in 2.539s
    found 0 vulnerabilities
    
    0 讨论(0)
提交回复
热议问题