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

16,275

Solution 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

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

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

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

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

Share:
16,275
Admin
Author by

Admin

Updated on July 07, 2022

Comments

  • Admin
    Admin almost 2 years

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

  • Carlos Cavero
    Carlos Cavero about 5 years
    First of all, welcome to StackOverflow. Following the advices of the community, it is recommended to include directly the images instead of links to better understand your response. Please check the documentation on how to create a Minimal, Complete, and Verifiable example
  • Nate Birkholz
    Nate Birkholz about 5 years
    What do you mean you "updated"? I have changed the line in pakage.json but it doesn't work, do I need to run a command to make it take effect?
  • Joel James
    Joel James almost 4 years
    This solution fixed my issue. Thanks dude