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

AngularTypescript

Angular Problem Overview


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"
                 }
               }

Angular Solutions


Solution 1 - Angular

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 - Angular

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

  1. Change like the below screenshot:

enter image description here

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

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

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

Solution 3 - Angular

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 - Angular

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 - Angular

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

Solution 6 - Angular

In your Package.json file remove ^ symbol (caret) from "rxjs": "^6.0.0" and add "rxjs": "6.0.0" it will work fine.

Solution 7 - Angular

Just change the TypeScript dependency version to ^2.8

Solution 8 - Angular

Your package.json has following lines:

"rxjs": "^6.0.0",

"typescript": "~2.7.2"

This tells npm to install the following versions

rxjs: Latest version in version 6 series which is 6.4.0

typescript: Latest patched version in minor version 2.7 which is 2.7.2

Now RxJS module also installs the type definition files for TypeScript. The type definition file included in the rxjs module that got installed in your project is not compatible with typescript version installed in the same project.

So as a solution in your package.json file you can either bump up the version of Typescript to say 2.8 as

"typescript": "^2.8.0"

or bump down the version of ngrx to something like

"ngrx": "~6.0.0" and

do a fresh npm install.

You can check the version number of the module installed by looking in following files:

node_modules/rxjs/package.json and
node_modules/typescript/package.json 

Solution 9 - Angular

Update in package.json rxjs": "6.3.3"

in terminal

  1. run npm update
  2. run ng serve

It should compile successfully

Solution 10 - Angular

Check your typescript version with below command.

~ tsc --version Version 3.3.3

As this is the latest typescript version, I've upgraded the project angular version to 7 by running below command in project home folder. It solved the issue.

~]# ng update @angular/cli @angular/core

Solution 11 - Angular

I changed the version for rxjs and typescript. My package.json has the following entries:

"typescript": "^2.7.2"
"rxjs": "^6.3.3",

I also had to upgrade angular cli.

Solution 12 - Angular

My current project is in asp.net MVC with angular 8. After updating the angular project from 8 to 9, the angular build working fine but facing the above problem for MVC build. (on azure)

Just hiding the

> node_modules

folder, solved my problem.

hide node_modules folder

Solution 13 - Angular

Seems like your Angular and/or rxjs version is not compatible with TypeScript.

Remove the ~ sign in the TypeScript version, add ^ instead. Then, install packages again.

Try running npm start and ng build prior to ng serve.

Solution 14 - Angular

These two changes what you want:

// in package.json:

"rxjs": "^6.2.2" ==> "rxjs": "latest"
"typescript": "2.7.2" ==> "typescript": "2.8"

where ==> means to replace

Solution 15 - Angular

I have tried all the other answers. But I found issue. I had ts lint plugin installed which forced file to be ended without space. I removed it and it is working.

You can also remove the space going to that specific file.

Solution 16 - Angular

You can update your npm version to the latest, if it isn't, with:

npm update -g

Solution 17 - Angular

I had to uninstall and reinstall angular CLI.

npm uninstall -g @angular/cli angular-cli
npm cache clean
npm install -g @angular/cli@latest
npm install -g @angular/cli@latest

Solution 18 - Angular

Encountered this error with: rxjs/store: ^6.4.0 typescript: ~2.7.2 angular/cli ~6.0.0

Updated everything to the latest except rxjs rxjs/store: ^6.3.3 typescript: ~3.1.1 angular/cli ~7.0.3

Basically I created an blank new project (ng new newProject) and installed @ngrx/store which brought down v6.3.3. This worked for me.

Solution 19 - Angular

Go to the project directory run:

npm install -s rxjs-compat

Solution 20 - Angular

The below steps resolved my issue

There are two files that have to modify.

  • node_modules\@ag-grid-community\core\dist\cjs\utils\index.js

> //export * from "./utils";

  • node_modules\@ag-grid-community\core\dist\cjs\utils\index.d.ts

> //_export(require("./utils"));

comment utils as above. now npm start

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRifat MurtuzaView Question on Stackoverflow
Solution 1 - AngularBolat KazybayevView Answer on Stackoverflow
Solution 2 - AngularimjayabalView Answer on Stackoverflow
Solution 3 - AngularAdityaView Answer on Stackoverflow
Solution 4 - AngularSwanand PangamView Answer on Stackoverflow
Solution 5 - AngularMakara SetView Answer on Stackoverflow
Solution 6 - AngularSagar JadhavView Answer on Stackoverflow
Solution 7 - AngularSanju VargheseView Answer on Stackoverflow
Solution 8 - AngularPraymView Answer on Stackoverflow
Solution 9 - AngularRamana YerramsettyView Answer on Stackoverflow
Solution 10 - AngularpavanView Answer on Stackoverflow
Solution 11 - AngularsthayamkeryView Answer on Stackoverflow
Solution 12 - AngularAnant DhasView Answer on Stackoverflow
Solution 13 - AngularCode_maniacView Answer on Stackoverflow
Solution 14 - AngularAli BahramiView Answer on Stackoverflow
Solution 15 - Angularpranav-devView Answer on Stackoverflow
Solution 16 - AngularHezy ZivView Answer on Stackoverflow
Solution 17 - AngularCaleb GramsView Answer on Stackoverflow
Solution 18 - AngularRobert PriceView Answer on Stackoverflow
Solution 19 - AngularAnil KumarView Answer on Stackoverflow
Solution 20 - AngularVijayView Answer on Stackoverflow