Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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"
                 }
               }
like image 380
Rifat Murtuza Avatar asked Jan 30 '19 06:01

Rifat Murtuza


3 Answers

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.

like image 120
Bolat Kazybayev Avatar answered Oct 09 '22 14:10

Bolat Kazybayev


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).

like image 41
imjayabal Avatar answered Oct 09 '22 15:10

imjayabal


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

like image 34
Aditya Avatar answered Oct 09 '22 15:10

Aditya