Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am getting an ERROR when compiling Angular 6 project

when starting my project ng serve i get this error. updated my ts and did not help.

here is the error

    ERROR in node_modules/@types/node/assert.d.ts(3,68): error TS1144: '{' or ';' expected.
    node_modules/@types/node/assert.d.ts(57,68): error TS1144: '{' or ';' expected.
    node_modules/@types/node/assert.d.ts(66,94): error TS1144: '{' or ';' expected.
    node_modules/@types/node/assert.d.ts(66,101): error TS1005: ';' expected.
    node_modules/@types/node/assert.d.ts(66,104): error TS1005: ';' expected.
    node_modules/@types/node/assert.d.ts(68,98): error TS1144: '{' or ';' expected.
    node_modules/@types/node/assert.d.ts(68,105): error TS1005: ';' expected.
    node_modules/@types/node/assert.d.ts(68,108): error TS1005: ';' expected.
    node_modules/@types/node/assert.d.ts(76,47): error TS1144: '{' or ';' expected.
    node_modules/@types/node/assert.d.ts(76,53): error TS1005: ';' expected.
    node_modules/@types/node/assert.d.ts(76,56): error TS1005: ';' expected.
    node_modules/@types/node/assert.d.ts(106,61): error TS1005: ';' expected.
    node_modules/@types/node/base.d.ts(10,1): error TS1084: Invalid 'reference' directive syntax.
    node_modules/@types/node/base.d.ts(11,1): error TS1084: Invalid 'reference' directive syntax.
    node_modules/@types/node/base.d.ts(12,1): error TS1084: Invalid 'reference' directive syntax.
    node_modules/@types/node/base.d.ts(13,1): error TS1084: Invalid 'reference' directive syntax.
    node_modules/@types/node/ts3.4/base.d.ts(10,1): error TS1084: Invalid 'reference' directive syntax.
    node_modules/@types/node/ts3.4/base.d.ts(11,1): error TS1084: Invalid 'reference' directive syntax.
    node_modules/@types/node/ts3.4/base.d.ts(12,1): error TS1084: Invalid 'reference' directive syntax.
    node_modules/@types/node/ts3.4/base.d.ts(13,1): error TS1084: Invalid 'reference' directive syntax.
    node_modules/@types/node/ts3.6/base.d.ts(10,1): error TS1084: Invalid 'reference' directive syntax.
    node_modules/@types/node/ts3.6/base.d.ts(11,1): error TS1084: Invalid 'reference' directive syntax.
    node_modules/@types/node/ts3.6/base.d.ts(12,1): error TS1084: Invalid 'reference' directive syntax.
    node_modules/@types/node/ts3.6/base.d.ts(13,1): error TS1084: Invalid 'reference' directive syntax.`

like image 714
Dias Zhumagaliyev Avatar asked Nov 20 '20 05:11

Dias Zhumagaliyev


2 Answers

This is probably an incompatibility issue between your TypeScript version and some of your @types packages. I'll walk you through the solution with a step by step example:

  1. Go to your package.json and look for you TypeScript and @types versions:
  "devDependencies": {
    // ...
    "@types/deep-freeze": "0.1.1",
    "@types/jasmine": "3.5.10",
    "@types/lodash.isequal": "4.5.5",
    "@types/lodash.mergewith": "4.6.6",
    "@types/lodash.remove": "4.7.6",
    "@types/lodash.some": "4.6.6",
    // ...
    "typescript": "2.9.2",
    // ...
  }
  1. For each of your @types packages do: npm dist-tags @types/<your-types-package-name>. You'll now see a table that indicates which TypeScript version works with each of the @types package version

  2. Update your @types in your package.json with the corresponding versions

If the solution does not work try updating TypeScript to a newer version!

like image 79
rbelow Avatar answered Nov 10 '22 19:11

rbelow


In case your using "typescript": "~3.1.6" in the package.json file, change "@types/node" version to "@types/node": "14.6.2", in the package.json file, That solved my problem..

like image 2
Mundruku Avatar answered Nov 10 '22 19:11

Mundruku