Definitelytyped: /node_modules/@types/lodash/common/object.d.ts (): Cannot find name 'Exclude'.

Created on 11 Mar 2019  ·  13Comments  ·  Source: DefinitelyTyped/DefinitelyTyped

Hello,

Beginning a few days ago, we began seeing the following when attempting to build an existing Angular2+ project making use of @types/lodash-es and lodash-es.

.../node_modules/@types/lodash/common/object.d.ts (): Cannot find name 'Exclude'.

This is causing a production build to no longer complete successfully.
The project is using:
"@types/lodash-es": "^4.14.5",
"lodash-es": "^4.17.4",
"typescript": "~2.3.2"

Per https://github.com/lodash/lodash/issues/4225 and https://stackoverflow.com/questions/55018665/following-lodash-error-on-build-cannot-find-name-exclude , it seems like there was a change put in place that relies on Typescript 2.8+

Can you please provide an update that does not require the typescript version to be updated past 2.3+?

Most helpful comment

You can install types for an old version of typescript with using npm tags. For example lodash types for typescript 2.5 npm i -D @types/[email protected].

All 13 comments

It looks to me that the problem might be being caused by the @types/lodash-es requiring "@types/lodash": "*" in the package-lock.json file. This results in the following entry in the package-lock.json file:

"@types/lodash": { "version": "4.14.123", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.123.tgz", },

version 4.14.123 contains a breaking change (uses Exclude which is only available in Typescript 2.8+).

How can I make use of a version of @types\lodash-es that does not cause the latest version of @types/lodash to be brought into/used in the project?

More detail provided in my question here: https://stackoverflow.com/questions/55123747/lodash-es-error-on-build-cannot-find-name-exclude

It looks to me like even previous versions of @types/lodash-es are causing the most recent version of @types/lodash to be brought into the project, which means the project won't build because @types/lodash 4.14.123 is not compatible with Typescript 2.3.* (because Exclude is used). However, I don't have control over which version of @types/lodash is required as this is handled indirectly @types/lodash-es which is the only related dependency I do have in the project...

package.json

{
"name": "Test",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"bundle-report": "webpack-bundle-analyzer dist/stats.json"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.2.5",
"@angular/common": "^4.2.5",
"@angular/compiler": "^4.2.5",
"@angular/compiler-cli": "^4.2.5",
"@angular/core": "^4.2.5",
"@angular/forms": "^4.2.5",
"@angular/http": "^4.2.5",
"@angular/platform-browser": "^4.2.5",
"@angular/platform-browser-dynamic": "^4.2.5",
"@angular/router": "^4.2.5",
"@asymmetrik/ngx-leaflet": "2.6.1",
"@asymmetrik/ngx-leaflet-draw": "2.7.1",
"@types/angular-ui-bootstrap": "^0.13.44",
"@types/fullcalendar": "^3.5.0",
"@types/googlemaps": "^3.26.14",
"@types/highcharts": "^5.0.36",
"@types/jquery": "^2.0.46",
"@types/jqueryui": "^1.11.35",
"@types/leaflet": "1.2.7",
"@types/leaflet-draw": "0.4.12",
"@types/moment": "^2.13.0",
"@types/node": "^6.0.79",
"@ultimate/ngxerrors": "^1.3.0",
"angular2-virtual-scroll": "^0.3.1",
"babel-regenerator-runtime": "^6.5.0",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"dragula": "^3.7.2",
"font-awesome": "^4.7.0",
"fullcalendar": "^3.6.2",
"fullcalendar-scheduler": "^1.9.3",
"highcharts": "6.2.0",
"jquery": "^3.2.1",
"jquery-ui-sortable": "^1.0.0",
"jqueryui": "^1.11.1",
"leaflet": "1.3.1",
"leaflet-draw": "1.0.2",
"lodash": "^4.17.4",
"moment": "^2.18.1",
"moment-timezone": "^0.5.14",
"ng-treetable": "^1.2.3",
"ng2-ckeditor": "1.1.9",
"ng2-dragula": "^1.5.0",
"ng2-pdf-viewer": "3.0.8",
"ngx-bootstrap": "^1.9.1",
"ngx-cookie-service": "^1.0.10",
"ngx-malihu-scrollbar": "^1.1.2",
"ngx-pipes": "~1.6.1",
"ngx-restangular": "^1.0.11",
"ngx-slick": "^0.1.3",
"primeng": "4.2.2",
"rxjs": "^5.1.0",
"slick-carousel": "^1.8.1",
"socket.io-client": "^2.0.4",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "^1.7.4",
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/leaflet": "1.2.7",
"@types/leaflet-draw": "0.4.12",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "2.3.4",
"webpack-bundle-analyzer": "^2.9.0"
}
}


Steps:

  1. rm -rf node_modules package-lock.json
  2. npm install
  3. ng serve

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

Got this above error. Any way to solve this??

If I replace the file ("/../node_modules/@types/lodash/common/object.d.ts") with "https://codeshare.io/adWzlB" code then it works...

ran into the similar issue, installed "4.14.121" version of @types/lodash and it works fine which seems more stable version and compatible with the typescript version that I've installed

dependencies is as below in my package.json file:

"dependencies": {
.........................,
"@types/lodash": "4.14.121",
"typescript": "2.5.3",
}

You can install types for an old version of typescript with using npm tags. For example lodash types for typescript 2.5 npm i -D @types/[email protected].

Just updated typescript@~2.8.x and the problem is gone!

@elouizbadr Did you experience slowness in the build after upgrading to typescript@~2.8.x. My build time takes too long, almost two times slower after upgrading to 2.8.x.

I was having same issue then I have followed @faizu88 steps and i got resolved the issue.

I have same problem. My solution is run below command

cd app
npm install @types/[email protected] --save-exact

Hope can help many person. :)

This case i face when i work on team that using same version nodejs and
npm. With same source code i cant build, and my friend dun have a problem.
When i check node_module and compare lodash. I found that the version is
different. The correct version is 4.14.116.

On Mon, May 20, 2019 at 10:41 PM Toby Thain notifications@github.com
wrote:

Is there a clear explanation and a sensible fix for this?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/33778?email_source=notifications&email_token=AELTPL2WSZ6YGC5FNLAIF3TPWLBEJA5CNFSM4G5FWYT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVZHTIQ#issuecomment-494041506,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AELTPL3O5YGZXAHUDSEBN3TPWLBEJANCNFSM4G5FWYTQ
.

npm i -D @types/[email protected]

this command worked for me too.

Just updated typescript@~2.8.x and the problem is gone!

I set typescript@~2.8.2 and it work!! thank you !!

Was this page helpful?
0 / 5 - 0 ratings