[at-loader] node_modules \ @types \ jasmine中的错误

时间:2017-02-11 20:57:47

标签: angular typescript npm webpack jasmine

我的webpack构建开始失败,没有更新软件包。我假设一些次要版本更新导致了这一点,但无法弄清楚如何解决它。有谁知道该怎么办?

ERROR in [at-loader] node_modules\@types\jasmine\index.d.ts:39:52 
    TS1005: '=' expected.
ERROR in [at-loader] node_modules\@types\jasmine\index.d.ts:39:38 
    TS2371: A parameter initializer is only allowed in a function or constructor implementation.
ERROR in [at-loader] node_modules\@types\jasmine\index.d.ts:39:46 
    TS2304: Cannot find name 'keyof'.

的package.json

  "dependencies": {
    "@angular/common": "2.4.7",
    "@angular/compiler": "~2.4.4",
    "@angular/core": "2.4.7",
    "@angular/forms": "2.4.7",
    "@angular/http": "~2.4.4",
    "@angular/material": "^2.0.0-beta.1",
    "@angular/platform-browser": "~2.4.4",
    "@angular/platform-browser-dynamic": "~2.4.4",
    "@angular/platform-server": "~2.4.4",
    "@angular/router": "~3.4.1",
    "@angularclass/conventions-loader": "^1.0.2",
    "@angularclass/hmr": "~1.2.2",
    "@angularclass/hmr-loader": "~3.0.2",
    "@vaadin/angular2-polymer": "^1.0.0",
    "animate.css": "^3.5.2",
    "assets-webpack-plugin": "^3.4.0",
    "bootstrap-sass": "^3.3.7",
    "bootstrap-select": "^1.12.1",
    "bootstrap-tour": "^0.11.0",
    "core-js": "^2.4.1",
    "font-awesome": "^4.7.0",
    "http-server": "^0.9.0",
    "icheck": "^1.0.2",
    "ie-shim": "^0.1.0",
    "jasmine-core": "^2.5.2",
    "metismenu": "2.0.2",
    "nestable": "^0.2.0",
    "ng2-modal": "0.0.24",
    "ng2-tag-input": "~0.8.4",
    "pace": "0.0.4",
    "pace-progress": "^1.0.2",
    "primeng": "^1.1.4",
    "reflect-metadata": "^0.1.9",
    "rxjs": "~5.1.0",
    "summernote": "^0.8.2",
    "zone.js": "0.7.4",
    "ag-grid": "~8.0.1",
    "ag-grid-enterprise": "~8.0.1",
    "ag-grid-ng2": "~8.0.0"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~2.4.1",
    "@types/hammerjs": "^2.0.33",
    "@types/jasmine": "^2.2.34",
    "@types/node": "^6.0.38",
    "@types/selenium-webdriver": "2.53.38",
    "@types/source-map": "^0.5.0",
    "@types/uglify-js": "^2.0.27",
    "@types/webpack": "^2.0.0",
    "angular-router-loader": "^0.4.0",
    "angular2-template-loader": "^0.6.0",
    "assets-webpack-plugin": "^3.4.0",
    "awesome-typescript-loader": "~3.0.4-rc.2",
    "codelyzer": "~2.0.0-beta.4",
    "copy-webpack-plugin": "^4.0.0",
    "css-loader": "^0.26.0",
    "exports-loader": "^0.6.3",
    "expose-loader": "^0.7.1",
    "extract-text-webpack-plugin": "^2.0.0-beta.4",
    "file-loader": "^0.9.0",
    "gh-pages": "^0.12.0",
    "html-webpack-plugin": "^2.21.0",
    "imports-loader": "^0.7.0",
    "istanbul-instrumenter-loader": "1.2.0",
    "jasmine-core": "^2.5.2",
    "json-loader": "^0.5.4",
    "karma": "^1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-coverage": "^1.1.1",
    "karma-jasmine": "^1.0.2",
    "karma-mocha-reporter": "^2.0.0",
    "karma-remap-coverage": "^0.1.4",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "1.8.1",
    "ngc-webpack": "^1.0.2",
    "node-sass": "^4.1.1",
    "npm-run-all": "^4.0.0",
    "parse5": "^3.0.1",
    "protractor": "^4.0.10",
    "raw-loader": "0.5.1",
    "rimraf": "~2.5.4",
    "sass-loader": "^4.1.1",
    "script-ext-html-webpack-plugin": "^1.3.2",
    "source-map-loader": "^0.1.5",
    "string-replace-loader": "1.0.5",
    "style-loader": "^0.13.1",
    "to-string-loader": "^1.1.4",
    "ts-helpers": "1.1.2",
    "ts-node": "^2.0.0",
    "tslint": "4.2.0",
    "tslint-loader": "^3.3.0", 
    "typedoc": "^0.5.3",
    "typescript": "2.0.10",
    "url-loader": "^0.5.7",
    "v8-lazy-parse-webpack-plugin": "^0.3.0",
    "webpack": "2.2.1",
    "webpack-dev-middleware": "^1.10.0",
    "webpack-dev-server": "2.3.0",
    "webpack-dll-bundles-plugin": "^1.0.0-beta.5",
    "webpack-md5-hash": "^0.0.5",
    "webpack-merge": "~2.6.1"
  }

3 个答案:

答案 0 :(得分:40)

看起来您的@types/jasmine库已升级到最新版本,因为您有插入符号:

"@types/jasmine": "^2.2.34",

最新版本存在问题,bug建议。因此,请尝试在package.json中将版本设置为2.5.41:

"devDependencies": {
  "@types/jasmine": "2.5.41"
}

也许您必须删除node-modules文件夹并运行npm install才能进行全新安装。

答案 1 :(得分:5)

如果您没有使用Angular 2,请将您的TypeScript更新为2.1.6或更高版本。这应该会有所帮助。

根据this discussion,更正确的解决方案是将TypeScript更新为for (var i = 0; i < rawElems.length; i++) { expanders[i] = new Expander(rawElems[i], false); expanders[i].element.addaddEventListener("click", handleExpanderClick.bind(expanders[i])); } function handleExpanderClick(event) { // `this` = the expander // `this.element` = the element // `event.currentTarget` = the element (also) } 分支的最新稳定次要版本,截至目前为止2.x(2017年2月12日) 。构建日志中的错误表明您使用的是过时的2.1.6版本。最新的2.0.10定义文件在jasmine函数中进行了新的语法检查,该函数仅适用于TypeScript spyOn()。一般来说,你没有理由坚持>=2.1.0,所以请升级。但是,如果存在阻止升级的向后兼容性问题,则应在此处填写问题表单:https://github.com/Microsoft/TypeScript/issues并使编译器团队了解错误。

UPD :避免使用2.0.10这样的行:package.json"typescript": "2.0.10。而不是"typescript": "~2.0.0"您应该应用~限制(允许更新次要版本号,而不仅仅是修补程序),例如^

希望有所帮助。很抱歉给您带来不便。

答案 2 :(得分:2)

即使使用Angular 2+,我也遇到了这个问题。什么解决了我的问题,而不是降级Jasmine正在更新Typescript。

我的步骤是:

  • package.json更改为指向新版本的打字稿
    • "typescript": "~2.0.9" - &gt; "typescript": "^2.0.9"
  • 运行npm install
  • 此后错误消失了。