18

My webpack build started failing out of nowhere with no packages being updated. I assume some minor version update caused this, but can't figure out how to get around it. Does anyone know what to do?

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"
  }
Josh
  • 1,648
  • 8
  • 27
  • 58

3 Answers3

40

Looks like your @types/jasmine library was upgraded to the latest version since you have the caret symbol:

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

The latest version is having issues as this bug suggests. So try for now by setting the version to 2.5.41 in your package.json :

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

Maybe you have to delete your node-modules folder and run npm install for a clean installation.

Daniel Mora
  • 2,589
  • 1
  • 25
  • 21
  • 1
    Thanks! I guess using the ^ is a risky idea seeing how often this seems to happen. – Josh Feb 12 '17 at 21:01
5

If you're not using Angular 2, update your TypeScript to 2.1.6 or higher, please. This should help.

According to this discussion, a more correct solution is to keep TypeScript updated to the latest stable minor version of 2.x branch, which is 2.1.6 as of now (Feb 12, 2017). The error you have in a build log indicates that you are using an outdated 2.0.10 version. The latest jasmine definition file has a new syntax check in spyOn() function which is available only for TypeScript >=2.1.0. Generally, you should have no serious reason to stick to 2.0.10, so, please upgrade. However, if there's a backward compatibility issue preventing you from the upgrade, you should fill in the issue form here: https://github.com/Microsoft/TypeScript/issues and make the compiler team aware of a bug.

UPD: Avoid in your package.json lines like these: "typescript": "2.0.10, "typescript": "~2.0.0". Instead of ~ you should apply ^ restriction (allows to update minor version numbers, not only hotfixes) like "typescript": ^2.0.0".

Hope that helps. Sorry for the inconvenience.

noomorph
  • 837
  • 1
  • 6
  • 14
  • How do I upgrade it? This was my first thought yesterday and I googled how to update it and ran the npm commands, but when I ran webpack it still said I was using the older version. – Josh Feb 12 '17 at 21:02
  • @Josh, I see that in your `package.json` there is a line `"typescript": "2.0.10"`. Could you please update it to `"typescript": "^2.0.10"` and run `npm update`? Does it help in your case? Thanks in advance. – noomorph Feb 13 '17 at 06:44
  • This is not a proper suggestion. Angular 2.x does *not* have support for TS 2.1.X. Angular 4.x will add that support. If you upgrade to Typescript 2.1.X then you risk having issues with AoT among other things. – sofly Feb 13 '17 at 20:27
  • Anyway, the 2.1.x support is planned to be backported into Angular 2.x, so even if it is not the case right now, my answer will be a more correct one in the future. Also, this answer can be helpful in other cases, when you've got a non-Angular2 project.@SoFLy, thank you very much for the comment, I'll update my answer. – noomorph Feb 14 '17 at 07:05
2

Even with Angular 2+ I had this problem. What solved the problem to me, instead of downgrading Jasmine was updating Typescript.

My steps were:

  • Change package.json to point to a new version of typescript
    • "typescript": "~2.0.9" -> "typescript": "^2.0.9"
  • Run npm install
  • After this the error was gone.
GarouDan
  • 3,743
  • 9
  • 49
  • 75