错误-node_modules \ @types \ jasmine \ index.d.ts(138,230)TS1005:')'预期

时间:2018-11-14 07:21:42

标签: typescript jasmine karma-jasmine

以下是我正在使用的版本  “ @ types /茉莉花”:“ ^ 2.8.9”  “ typescript”:“〜2.6.2”

 "devDependencies": {
        "@ionic/app-scripts": "3.2.0",
        "@types/jasmine": "^2.8.9",
        "@types/node": "^10.12.5",
        "angular2-template-loader": "^0.6.2",
        "html-loader": "^0.5.5",
        "istanbul-instrumenter-loader": "^3.0.1",
        "jasmine": "^3.3.0",
        "jasmine-spec-reporter": "^4.2.1",
        "karma": "^3.1.1",
        "karma-chrome-launcher": "^2.2.0",
        "karma-coverage-istanbul-reporter": "^2.0.4",
        "karma-jasmine": "^1.1.2",
        "karma-jasmine-html-reporter": "^1.4.0",
        "karma-sourcemap-loader": "^0.3.7",
        "karma-webpack": "^3.0.5",
        "null-loader": "^0.1.1",
        "protractor": "^5.4.1",
        "ts-loader": "^3.5.0",
        "ts-node": "^7.0.1",
        "typescript": "~2.6.2"
      },

但是仍然出现以下错误

Error: node_modules/@types/jasmine/index.d.ts(138,47): error TS1005: ';' expected.
node_modules/@types/jasmine/index.d.ts(138,90): error TS1005: '(' expected.
node_modules/@types/jasmine/index.d.ts(138,104): error TS1005: ']' expected.
node_modules/@types/jasmine/index.d.ts(138,112): error TS1005: ',' expected.
node_modules/@types/jasmine/index.d.ts(138,113): error TS1136: Property assignment expected.
node_modules/@types/jasmine/index.d.ts(138,121): error TS1005: ')' expected.
node_modules/@types/jasmine/index.d.ts(138,147): error TS1005: '(' expected.
node_modules/@types/jasmine/index.d.ts(138,162): error TS1005: ']' expected.
node_modules/@types/jasmine/index.d.ts(138,163): error TS1005: ',' expected.
node_modules/@types/jasmine/index.d.ts(138,164): error TS1136: Property assignment expected.
node_modules/@types/jasmine/index.d.ts(138,165): error TS1136: Property assignment expected.
node_modules/@types/jasmine/index.d.ts(138,179): error TS1005: ',' expected.
node_modules/@types/jasmine/index.d.ts(138,183): error TS1005: ':' expected.
node_modules/@types/jasmine/index.d.ts(138,208): error TS1005: '{' expected.
node_modules/@types/jasmine/index.d.ts(138,217): error TS1005: ':' expected.
node_modules/@types/jasmine/index.d.ts(138,222): error TS1005: ',' expected.
node_modules/@types/jasmine/index.d.ts(138,227): error TS1005: ':' expected.
node_modules/@types/jasmine/index.d.ts(138,228): error TS1109: Expression expected.
node_modules/@types/jasmine/index.d.ts(138,230): error TS1005: ')' expected.

我没有解决该问题的方法。 谁能帮我。

6 个答案:

答案 0 :(得分:8)

如果仍然有问题,请在package.json中添加

“打字稿”:“ ^ 2.9.2”

运行npm install。

应该可以。

答案 1 :(得分:3)

我已修复它更改了我的软件包版本:

"@types/jasmine": "2.8.6",
"@types/jasminewd2": "2.0.3",

在此职位中建立: Angular 4+ : Sudden @types/jasmine error at runtime (npm start)

答案 2 :(得分:0)

尝试一下:安装ncu

npm install -g npm-check-updates

轻松更新tsc:

ncu -u
npm install

仅此而已,尽情享受!。

答案 3 :(得分:0)

  1. 第1步。您需要在package.json中的2.8.6或2.8.9之前删除“〜”
  2. 步骤2。删除package-lock.json文件和node_modules文件夹
  3. 第3步。运行“ npm cache clean --force”和“ npm install”

答案 4 :(得分:0)

如果您未在应用程序中的任何地方使用Jasmine时到达此页面,那么我建议您检查ts文件顶部的import语句。它应该在顶部添加:

import { ConsoleReporter } from 'jasmine';

当我使用控制台对象登录浏览器并且VS Code的自动完成功能通过ConsoleReporter完成并添加了此导入语句时,我意外地将此添加到顶部。删除此语句解决了我的问题。

答案 5 :(得分:0)

您刚刚更改了typescript@2.8.4和@ types / jasmine @ 2.8.3

  1. npm安装typescript@2.8.4 --save-dev
  2. npm install @ types / jasmine @ 2.8.3 --save-dev

工作100%。

谢谢