'following lodash error on build 'Cannot find name 'Exclude''

I am getting following lodash error

ERROR in node_modules/@types/lodash/common/object.d.ts(1689,12): error TS2304: Cannot find name 'Exclude'. node_modules/@types/lodash/common/object.d.ts(1766,12): error TS2304: Cannot find name 'Exclude'. node_modules/@types/lodash/common/object.d.ts(1842,34): error TS2304: Cannot find name 'Exclude'.



Solution 1:[1]

Solution 1
I also had the same issue, i tried to downgrade typescript version and lodash version, but nothing worked, and at last i tried installing @types/lodash, and it worked. just try this:

npm i @types/lodash

hope it helps.

If the above solution doesn't work try this:

Solution 2
The actual issue is, Exclude was added to typescript on version 2.8. You might have a version of @types/lodash that needs minimum typescript 2.8, and it can happen if your lodash and typescript version didn't match.

So, install the last typescript 2.3 version compatible with lodash using this code :

npm i -D @types/[email protected]

Solution 2:[2]

I'm facing the same issue this morning. One possible solution for me is to fix the lodash version in the package.json :

"lodash": "^4.17.4" => "lodash": "4.17.4"

"@types/lodash": "^4.14.55" => "@types/lodash": "4.14.55"

And waiting for a more stable fix/solution.

Hope that works for you

Solution 3:[3]

There are recent updates on lodash typings reference : https://www.npmjs.com/package/@types/lodash Last updated: Mon, 04 Mar 2019 22:42:42 GMT

changing "@types/lodash": "4.14.121" worked for me as this was the most stable version referred prior to recent update.

Hope this helps.

Solution 4:[4]

I have the same error for this evening. I try to re-install all of them but nothing happend.

Current I use:

Typescript: 2.2.2 - Ionic: 3, Ionic CLI: 4.1.2 - Cordova: 8.1.2 - Angular CLI: 1.2.4

My solution for now: Set the typesript version to 3.2.4 => It work for me

Updated For now, I fix issue by force install the lodash: npm install --save @types/[email protected]

Solution 5:[5]

I solved this problem indirectly.

  1. Find @types/lodash in package-lock.json enter image description here

  2. Update package.json enter image description here

Solution 6:[6]

I have the same error since 2 days.

my package.json:

{
  "name": "my-app",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "prod": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.1.1",
    "@angular/common": "^4.0.1",
    "@angular/compiler": "^4.0.1",
    "@angular/core": "^4.0.1",
    "@angular/forms": "^4.0.1",
    "@angular/http": "^4.0.1",
    "@angular/platform-browser": "^4.0.1",
    "@angular/platform-browser-dynamic": "^4.0.1",
    "@angular/router": "^4.0.1",
    "angular2-json-schema-form": "https://github.com/ptv-ldts/angular2-json-schema-form/tarball/impact?v1.0.2",
    "angular2-notifications": "^0.7.3",
    "bootstrap": "^3.3.7",
    "clipboard": "^1.6.1",
    "core-js": "^2.4.1",
    "gulp": "^3.9.1",
    "gulp-cheerio": "^0.6.2",
    "gulp-clean": "^0.3.2",
    "gulp-rename": "^1.2.2",
    "lodash": "^4.17.4",
    "ng2-ace-editor": "^0.1.9",
    "ng2-bs3-modal": "^0.10.4",
    "ng2-smart-table": "1.2.1",
    "ngx-clipboard": "^5.1.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0",
    "@angular/compiler-cli": "^4.0.1",
    "@types/jasmine": "2.5.38",
    "@types/lodash": "^4.14.55",
    "@types/node": "~6.0.60",
    "angular-ide": "^0.9.19",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "jquery": "^3.2.1",
    "json-loader": "^0.5.4",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-coverage": "^1.1.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-junit-reporter": "^1.2.0",
    "karma-phantomjs-launcher": "^1.0.4",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.2.0"
  },
  "peerDependencies": {
    "rxjs": "^5.1.0"
  }
}

Update: What I found was, that exclude comes in with typescript 2.8. I changed the line in package json for typescript to "typescript": "^2.2.0" and updated.

Solution 7:[7]

We faced this issue and we had to increment the typescript version to "2.8" to solve the "Exclude" error.

Note: Make sure to use the typescript version which is required by your @angular/cli version.

Like, in my case @angluar/cli version is "6.0.8" which can accept typescript version "2.8".

Solution 8:[8]

For me, it appeared to be a change of lodash from 4.14.118 -> 4.14.122. Fixing at 4.14.118 fixed this issue.

"@types/lodash": "4.14.118",

Solution 9:[9]

In my case, I had to update angular-tree-component from 7.2.0 to 8.2.0 and the problem got resolved!

Solution 10:[10]

We have faced the same issue but it got resolved after I change the version of lodash from - "@types/lodash": "^4.14.111" to "@types/lodash": "4.14.121" in the package.json file

Solution 11:[11]

I faced the same issue. I solved it by installing lodash with below command

npm install --save @types/[email protected]

Check the version mentioned in Package.json and install corresponding version to resolve the issue.

Solution 12:[12]

You can try to install older verison of typescript : Example npm i -D @types/[email protected]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 adiga
Solution 3 adiga
Solution 4
Solution 5 Saravana
Solution 6
Solution 7 Kalyan
Solution 8 Tirinoarim
Solution 9
Solution 10 adiga
Solution 11
Solution 12 Prateek