Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 969
Rajesh Reddy Avatar asked Mar 06 '19 08:03

Rajesh Reddy


3 Answers

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]
like image 60
Gaius Avatar answered Oct 17 '22 17:10

Gaius


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

like image 8
Yuan Avatar answered Oct 17 '22 18:10

Yuan


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.

like image 6
Ish Avatar answered Oct 17 '22 16:10

Ish