代码之家  ›  专栏  ›  技术社区  ›  Torab Shaikh

生成突然开始失败,出现错误TS2304:找不到名称“jQueryDeferred”

  •  0
  • Torab Shaikh  · 技术社区  · 6 年前

    我在用 ng2-tel-input 在我的Angular应用程序中,到目前为止它工作得很好,但是突然我开始出错。

    node_modules/@types/intl-tel-input/index.d.ts(111,30): error TS2304: Cannot find name 'JQueryDeferred'.
    

    我的 ng2-tel-input 标签是

    <input type="text" ng2TelInput [ng2TelInputOptions]="mobilePhoneInputOptions"
    (ng2TelOutput)="getNumber($event)"
    (intlTelInputObject)="telInputObject($event)"
    (hasError)="hasError($event)"
     [(ngModel)]="selectedDriver.attributes.mobile_phone"
      (countryChange)="onCountryChange($event)" /> 
    

    默认情况下 mobilePhoneInputOptions

    public mobilePhoneInputOptions: any = {
        initialCountry: 'us',
        separateDialCode: true
      };
    

    然后根据数据变化。

    我的 package.json

    {
      "name": "ProjectName",
      "version": "1.0.0",
      "license": "MIT",
      "angular-cli": {},
      "scripts": {
        "lint": "tslint \"src/**/*.ts\"",
        "test": "ng test",
        "pree2e": "webdriver-manager update",
        "e2e": "protractor"
      },
      "private": true,
      "dependencies": {
        "@angular-devkit/core": "^7.1.0",
        "@angular/animations": "7.1.0",
        "@angular/cdk": "^7.1.0",
        "@angular/common": "7.1.0",
        "@angular/compiler": "7.1.0",
        "@angular/compiler-cli": "7.1.0",
        "@angular/core": "^7.1.0",
        "@angular/flex-layout": "^7.0.0-beta.19",
        "@angular/forms": "7.1.0",
        "@angular/http": "7.1.0",
        "@angular/material": "7.1.0",
        "@angular/platform-browser": "7.1.0",
        "@angular/platform-browser-dynamic": "7.1.0",
        "@angular/router": "7.1.0",
        "@angular/upgrade": "7.1.0",
        "@fortawesome/angular-fontawesome": "^0.3.0",
        "@fortawesome/fontawesome-svg-core": "^1.2.9",
        "@fortawesome/free-solid-svg-icons": "^5.6.0",
        "@swimlane/ngx-datatable": "^14.0.0",
        "@types/chart.js": "^2.7.40",
        "@types/intl-tel-input": "^14.0.0",
        "angular-bootstrap-md": "^6.3.0",
        "angular-file": "^0.5.8",
        "angular2-cookie": "^1.2.6",
        "angular2-notifications": "^1.0.4",
        "angular2-uuid": "^1.1.1",
        "angular5-csv": "^0.2.10",
        "angulartics2": "^2.4.0",
        "aws-api-gateway-client": "^0.2.16",
        "aws-sdk": "^2.386.0",
        "axios": "^0.16.2",
        "axios-retry": "^2.0.1",
        "buffer": "^5.2.1",
        "chart.js": "^2.5.0",
        "core-js": "^2.4.1",
        "crypto-js": "^3.1.9-1",
        "font-awesome": "^4.7.0",
        "hammerjs": "^2.0.8",
        "hot-formula-parser": "^2.0.3",
        "intl-tel-input": "^14.0.7",
        "jquery": "^3.3.1",
        "mdbootstrap": "^4.5.15",
        "moment": "^2.18.1",
        "ng2-mqtt": "^0.1.2",
        "ng2-tel-input": "^1.0.15",
        "ngx-pagination": "^3.2.1",
        "rxjs": "^6.3.3",
        "rxjs-compat": "^6.0.0-rc.0",
        "ts-helpers": "1.1.2",
        "ts-md5": "^1.2.0",
        "tslib": "^1.9.0",
        "url-template": "^2.0.8",
        "uuid": "^3.3.2",
        "webdriver-manager": "^12.0.5",
        "zone.js": "^0.8.26"
      },
      "devDependencies": {
        "@angular-devkit/build-angular": "~0.11.0",
        "@angular/cli": "^7.1.0",
        "@angular/compiler-cli": "7.1.0",
        "@angular/language-service": "7.1.0",
        "@angular/platform-browser": "7.1.0",
        "@angular/platform-browser-dynamic": "7.1.0",
        "@angular/platform-server": "7.1.0",
        "@types/hammerjs": "^2.0.33",
        "@types/jasmine": "~2.8.3",
        "@types/jasminewd2": "~2.0.2",
        "@types/node": "^7.0.32",
        "aws-sdk-typescript": "0.0.3",
        "codelyzer": "^4.0.1",
        "css-loader": "^0.28.0",
        "extract-text-webpack-plugin": "^2.1.2",
        "jasmine-core": "~2.8.0",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "~2.0.0",
        "karma-chrome-launcher": "~2.2.0",
        "karma-coverage-istanbul-reporter": "^1.2.1",
        "karma-jasmine": "~1.1.0",
        "karma-jasmine-html-reporter": "^0.2.2",
        "node-sass": "^4.10.0",
        "protractor": "^5.4.1",
        "raw-loader": "^0.5.1",
        "rebuild-node-sass": "^1.1.0",
        "sass-loader": "^6.0.6",
        "ts-node": "^3.1.0",
        "tslint": "^5.11.0",
        "typescript": "3.1.6",
        "webdriver-manager": "^12.0.0"
      }
    }
    

    还有我的 angular.json

    {
      "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
      "version": 1,
      "newProjectRoot": "projects",
      "projects": {
        "project-name": {
          "root": "",
          "sourceRoot": "src",
          "projectType": "application",
          "architect": {
            "build": {
              "builder": "@angular-devkit/build-angular:browser",
              "options": {
                "outputPath": "dist",
                "index": "src/index.html",
                "main": "src/main.ts",
                "tsConfig": "src/tsconfig.json",
                "assets": [
                  "src/assets",
                  "src/favicon.ico"
                ],
                "styles": [
                  "src/assets/css/pure.css",
                  "src/assets/css/flexbox.css",
                  "src/assets/css/style.css",
                  "src/assets/css/modal.css",
                  "node_modules/intl-tel-input/build/css/intlTelInput.css",
                  "src/styles.scss"
                ],
                "scripts": [
                  "node_modules/aws-sdk/dist/aws-sdk.js",
                  "node_modules/hot-formula-parser/dist/formula-parser.min.js",
                  "src/lib/google-tag-manager/stage.js",
                  "node_modules/chart.js/dist/Chart.js",
                  "node_modules/hammerjs/hammer.min.js"
                ]
              },
              "configurations": {
                "dev": {
                  "fileReplacements": [
                    {
                      "replace": "src/environments/environment.ts",
                      "with": "src/environments/environment.dev.ts"
                    }
                  ]
                },
                "production": {
                  "optimization": true,
                  "outputHashing": "all",
                  "sourceMap": false,
                  "extractCss": true,
                  "namedChunks": false,
                  "aot": true,
                  "extractLicenses": true,
                  "vendorChunk": false,
                  "buildOptimizer": true,
                  "fileReplacements": [
                    {
                      "replace": "src/environments/environment.ts",
                      "with": "src/environments/environment.prod.ts"
                    }
                  ]
                },
                "stage": {
                  "fileReplacements": [
                    {
                      "replace": "src/environments/environment.ts",
                      "with": "src/environments/environment.stage.ts"
                    }
                  ]
                }
              }
            },
            "serve": {
              "builder": "@angular-devkit/build-angular:dev-server",
              "options": {
                "browserTarget": "project-name:build"
              },
              "configurations": {
                "dev": {
                  "browserTarget": "project-name:build:dev"
                },
                "production": {
                  "browserTarget": "project-name:build:production"
                },
                "stage": {
                  "browserTarget": "project-name:build:stage"
                }
              }
            },
            "extract-i18n": {
              "builder": "@angular-devkit/build-angular:extract-i18n",
              "options": {
                "browserTarget": "project-name:build"
              }
            },
            "test": {
              "builder": "@angular-devkit/build-angular:karma",
              "options": {
                "main": "src/test.ts",
                "karmaConfig": "./karma.conf.js",
                "scripts": [
                  "node_modules/aws-sdk/dist/aws-sdk.js",
                  "node_modules/hot-formula-parser/dist/formula-parser.min.js",
                  "src/lib/google-tag-manager/stage.js",
                  "node_modules/chart.js/dist/Chart.js",
                  "node_modules/hammerjs/hammer.min.js"
                ],
                "styles": [
                  "src/material2-app-theme.scss",
                  "node_modules/font-awesome/scss/font-awesome.scss",
                  "node_modules/angular-bootstrap-md/scss/bootstrap/bootstrap.scss",
                  "node_modules/angular-bootstrap-md/scss/mdb-free.scss",
                  "node_modules/intl-tel-input/build/css/intlTelInput.css",
                  "src/styles.scss"
                ],
                "assets": [
                  "src/assets",
                  "src/favicon.ico"
                ]
              }
            },
            "lint": {
              "builder": "@angular-devkit/build-angular:tslint",
              "options": {
                "tsConfig": [],
                "exclude": []
              }
            }
          }
        },
        "project-name-e2e": {
          "root": "e2e",
          "sourceRoot": "e2e",
          "projectType": "application",
          "architect": {
            "e2e": {
              "builder": "@angular-devkit/build-angular:protractor",
              "options": {
                "protractorConfig": "./protractor.conf.js",
                "devServerTarget": "project-name:serve"
              }
            },
            "lint": {
              "builder": "@angular-devkit/build-angular:tslint",
              "options": {
                "tsConfig": [],
                "exclude": []
              }
            }
          }
        }
      },
      "defaultProject": "project-name",
      "schematics": {
        "@schematics/angular:component": {
          "prefix": "app",
          "styleext": "scss"
        },
        "@schematics/angular:directive": {
          "prefix": "app"
        }
      }
    }
    

    我把这个包裹放在另一个运行良好的地方。 到目前为止,我已经尝试过了

    npm install intl-tel-input
    npm install @types/intl-tel-input
    npm install ng2-tel-input
    npm install jquery
    npm install @types/jquery
    

    我还尝试删除 node_modules 文件夹,然后运行 npm i . 我还评论了我使用包的两个标签,但是我仍然得到同样的错误。我有什么需要尝试的吗?我找不到任何与 JQueryDeferred .

    1 回复  |  直到 5 年前
        1
  •  0
  •   Torab Shaikh    5 年前

    我已经通过从本地删除repo解决了这个问题,并再次从bitback中签出repo,运行 npm i 问题就消失了。这很奇怪,因为我多次从repo中提取代码并删除然后重新安装 节点模块 . 我现在接受我的回答。我不明白是什么导致了这个问题,我所做的并不是一个合适的解决方案,所以如果以防万一 有人可以解释或提供解决方案,我会选择这个作为答案。 .