Error TS1005: ';' expected. TypeScript Angular 6 For First Build error rxjs inside node_modules

94,649

Solution 1

I had the same issue. I investigated that rxjs released a new version: 6.4.0. And it broke the build. According to review, the minimum supported version of TypeScript is 2.8. If you don't want to update TypeScript version, just change "rxjs": "^6.0.0", to "rxjs": "6.3.3" in package.json.

Solution 2

I was facing the same issue while developing an angular6 project. I spent more time finally it's working for me.

Here is the solution:

  1. Open "package.json"

  2. rxjs and "TypeScript" verstion like below screenshot

    enter image description here

  3. Change like the below screenshot:

    enter image description here

  4. Next go to your project folder and delete "node_modules" folder.

  5. After delete, next run npm install in your project folder

  6. Finally run ng serve. It should work (I tried 3 projects and confirmed).

Solution 3

Just remove ^ character from "rxjs": "^6.0.0" from package.json file and make it "rxjs": "6.0.0". It should work fine.

Solution 4

Today I faced the same issue. None of the above answers worked except a comment from one @Nasreen Ustad. So what you have to do is:

  1. Go to package.json and modify "rxjs": "^6.0.0" to "rxjs": "6.0.0"
  2. Run npm update in your project

No need to change typescript version.(Mine: "typescript": "~2.7.2")

Solution 5

Go to the project directory run: npm install [email protected] --save

Share:
94,649

Related videos on Youtube

Rifat Murtuza
Author by

Rifat Murtuza

Updated on June 15, 2022

Comments

  • Rifat Murtuza
    Rifat Murtuza less than a minute

    I'm building my first Angular Application. I'm creating a new Angular application using this command ng new purchase-section. But when I executing the application using ng serve -o I got the following error.

    ERROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' expected. node_modules/rxjs/internal/types.d.ts(81,74): error TS1005: ';' expected. node_modules/rxjs/internal/types.d.ts(81,77): error TS1109: Expression expected.

    I have inspected types.d.ts as I know it is created by Angular. I'm not able to understand the error. Note that after I got this error I deleted node_modules and I installed using npm install wished I got away still I got this error.

    Here is my package.JSON file:

    {
     "name": "purchase-section",
     "version": "0.0.0",
      "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
     },
     "private": true,
       "dependencies": {
        "@angular/animations": "^6.0.3",
         "@angular/common": "^6.0.3",
         "@angular/compiler": "^6.0.3",
         "@angular/core": "^6.0.3",
         "@angular/forms": "^6.0.3",
          "@angular/http": "^6.0.3",
          "@angular/platform-browser": "^6.0.3",
          "@angular/platform-browser-dynamic": "^6.0.3",
          "@angular/router": "^6.0.3",
           "core-js": "^2.5.4",
           "rxjs": "^6.0.0",
            "zone.js": "^0.8.26"
           },
          "devDependencies": {
            "@angular-devkit/build-angular": "~0.6.8",
             "@angular/cli": "~6.0.8",
             "@angular/compiler-cli": "^6.0.3",
              "@angular/language-service": "^6.0.3",
               "@types/jasmine": "~2.8.6",
               "@types/jasminewd2": "~2.0.3",
                "@types/node": "~8.9.4",
                 "codelyzer": "~4.2.1",
                  "jasmine-core": "~2.99.1",
                   "jasmine-spec-reporter": "~4.2.1",
                    "karma": "^4.0.0",
                     "karma-chrome-launcher": "~2.2.0",
                      "karma-coverage-istanbul-reporter": "~2.0.0",
                       "karma-jasmine": "~1.1.1",
                     "karma-jasmine-html-reporter": "^0.2.2",
                     "protractor": "^5.4.2",
                      "ts-node": "~5.0.1",
                      "tslint": "~5.9.1",
                    "typescript": "~2.7.2"
                     }
                   }
    
    • martin
      martin over 3 years
      Related issue on RxJS GitHub page: github.com/ReactiveX/rxjs/issues/4512
    • yfdgvf asdasdas
      yfdgvf asdasdas over 3 years
      Hey did you ever find a answer to this problem, I am having the same issue and none of the below answers solved anything. By the way I am using ng4(Angular 4).
    • user3629249
      user3629249 over 3 years
      which line is line 81?
    • Inzamam Malik
      Inzamam Malik over 2 years
  • Code_maniac
    Code_maniac over 3 years
    Restart Visual Studio after this. What is your TS version now?
  • kalai
    kalai over 3 years
    i have same issue my "typescript": "~3.2.2" and "rxjs": "6.3.3" please tell me anyone how to solve this error?
  • Viocartman
    Viocartman over 3 years
    This seems to work for me but do you know what the actual reason for this error is ? I mean until now it worked fine with the "^" symbol. Do you maybe have more details regarding what is causing this error ? Thanks
  • Jeremy Thille
    Jeremy Thille over 3 years
    I then had to delete my node_modules and run npm i again, but it worked. (Alternative : npm update)
  • Nasreen Ustad
    Nasreen Ustad over 3 years
    just change "rxjs": "^6.0.0", to "rxjs": "6.3.3" in package.json and run command npm install again so it will update it in your project. Now It will work
  • double-beep
    double-beep over 3 years
    This is just a duplicate answer of this one IMO. Before posting here, check the other answers.
  • bakytn
    bakytn over 3 years
    this helped me. Thanks! (new version 2.9.2 worked perfectly)
  • rohan dani
    rohan dani over 3 years
    Also if your package.json has a dependency for rxjs-compat then make that also 6.3.3 so you will not get any errors
  • codemt
    codemt over 3 years
    @kalai hi , i had the same problem , i changed rxjs version to 6.3.3 , and removed node modules and installed again , and now it is working , i am using typescript version 2.7.2
  • Prageeth godage
    Prageeth godage over 3 years
    for details read @langrenn answer in below I think it is the reason.
  • kalai
    kalai over 3 years
    @codemt my project running successfully on command prompt but getting error only in visual studio 2017
  • codemt
    codemt over 3 years
    @kalai then it looks some problem with VS version , upgrade to the latest version and see what happens.
  • Swanand Pangam
    Swanand Pangam almost 2 years
    @shubham actually I have now moved to angular 10. Couldn't simulate this.
  • Anish Sinha
    Anish Sinha 9 months
    yes thanks - visual studio excludes node_modules when it is hidden.
  • Bionix1441
    Bionix1441 5 months
    I have the same problem, but this does not help me to fix the problem. Any ideas? I am trying to run the command npm start for the following project github.com/angulardeveloper-io/ngrx-store-app.