Noy M
Noy M

Reputation: 361

ERROR in node_modules/@types/babel__traverse/index.d.ts(68,50): error TS1005: ']' expected

I'm updating angular 5 to 6V.

I followed all the steps in the guide - https://update.angular.io/?v=5.2-6.0

ng version
Angular CLI: 6.2.9
Node: 14.15.5
OS: linux x64
Angular: 6.1.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.6.8
@angular-devkit/schematics        0.8.9
@angular/cdk                      5.2.5
@angular/cli                      6.2.9
@angular/material                 5.2.5
@angular/platform-server          5.2.10
@ngtools/webpack                  6.0.8
@schematics/angular               0.8.9
@schematics/update                0.8.9
rxjs                              6.0.0
typescript                        2.9.2
webpack                           4.8.3

now when im running ng serve I'm getting a large error msg regarding my @type

example:

ERROR in node_modules/@types/babel__traverse/index.d.ts(68,50): error TS1005: ']' expected.
node_modules/@types/babel__traverse/index.d.ts(68,53): error TS1005: ';' expected.
node_modules/@types/babel__traverse/index.d.ts(68,58): error TS1005: ';' expected.
node_modules/@types/babel__traverse/index.d.ts(68,70): error TS1011: An element access expression should take an argument.
node_modules/@types/babel__traverse/index.d.ts(68,83): error TS1005: ';' expected.
node_modules/@types/babel__traverse/index.d.ts(68,84): error TS1128: Declaration or st

In my research, I saw that I have to update Typescript to a newer version, when updating to the latest im getting an error saying I must use typescript@">=2.7.2 <2.10" (now im using "typescript": "^2.9.2", ) I ran this command but it still returns the same error. Any idea?

Upvotes: 20

Views: 43326

Answers (4)

Falcon
Falcon

Reputation: 468

Less offensive approach is to add babel dependencies to your package.json file:

"typescript": "3.8.3",
"@types/babel__core": "7.1.18",
"@types/babel__traverse": "7.14.2",

After this run npm install

You can match babel version to typescript by information included in their package repositories (check column named 'Tag').

https://www.npmjs.com/package/@types/babel__traverse?activeTab=versions

https://www.npmjs.com/package/@types/babel__core?activeTab=versions

In my case babel version was overridden by newest because of installation of other package that depend on it.

Solution author:

https://stackoverflow.com/a/74824145/9950085

Upvotes: 16

Zhanghao Mo
Zhanghao Mo

Reputation: 191

"ts-node": "^10.8.1", "typescript": "^4.6.3" finally worked for me!

Upvotes: 19

Noy M
Noy M

Reputation: 361

npm i [email protected]

solved the issue

Upvotes: 8

yanir midler
yanir midler

Reputation: 2702

Try updating the Typescript to a newer version. Worked for me.

"typescript" - "^3.4.2"

Upvotes: 6

Related Questions