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

心不动则不痛 提交于 2019-12-08 18:14:07

问题


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


回答1:


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.




回答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




回答3:


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/lodash@4.14.118




回答4:


I solved this problem indirectly.

  1. Find @types/lodash in package-lock.json

  2. Update package.json




回答5:


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/lodash@ts2.3



回答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.




回答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".




回答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",




回答9:


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




回答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



来源:https://stackoverflow.com/questions/55018665/following-lodash-error-on-build-cannot-find-name-exclude

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!