0

i'm using angular metirials with angular-cli by using this guide and dealing with this error
when runing the ng serve command: Initializers are not allowed in ambient contexts

I assume it has problem with my packages versions but i failed to fix it

my package.json

  "dependencies": {
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/material": "^2.0.0-beta.3",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "@angular2-material/button": "^2.0.0-alpha.8-3",
    "@angular2-material/core": "^2.0.0-alpha.8-3",
    "core-js": "^2.4.1",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^2.3.1",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.28.3",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "~4.0.13",
    "ts-node": "1.2.1",
    "tslint": "^4.3.0",
    "typescript": "~2.0.3"
  }
}

NOTES

My error:enter image description here

3 Answers 3

1

You need "typescript": "2.1.0" in your package.json dev-dependencies

Sign up to request clarification or add additional context in comments.

1 Comment

did you try updating to typescript 2.2.0?
0

I tried different approach to fix this issue and it worked for me:

  1. i updated the angular-cli version using this guide
    Note: not sure if its a must step but it fixed issues for me
  2. created new app using the new cli version
  3. used this guide to install the materials package

Comments

0

Update your Typescript to a latest version, use this command:

npm install -g typescript@latest

Now run the application again with 'ng serve'. It should work.

If it doesnt work follow https://github.com/angular/angular-cli/wiki/stories-1.0-update and install @angular/material again. You may get this error that " Cannot find module '@angular/animations'". In this case use below cmd:

npm install @angular/animations

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.