【问题标题】:Error with jasmine node module in angular 2angular 2 中的 jasmine 节点模块出错
【发布时间】:2017-07-25 00:14:42
【问题描述】:

我收到以下错误,

  • 我已尝试更改我的 typescript 版本,但这并不能解决问题 问题。
  • 我试过运行npm update --save,但仍然没有 有效。

    [默认] /Users/gdayton/Documents/auction/node_modules/@types/jasmine/index.d.ts:39:37 中的错误 参数初始化器只允许在函数或构造函数实现中使用。

    [默认] /Users/gdayton/Documents/auction/node_modules/@types/jasmine/index.d.ts:39:45 中的错误 找不到名称“keyof”。

    [默认] /Users/gdayton/Documents/auction/node_modules/@types/jasmine/index.d.ts:39:51 中的错误 '=' 预期。

这是我的 package.json 文件。

{
  "name": "auction2",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "2.0.0",
    "@angular/compiler": "2.0.0",
    "@angular/core": "2.0.0",
    "@angular/forms": "2.0.0",
    "@angular/http": "2.0.0",
    "@angular/platform-browser": "2.0.0",
    "@angular/platform-browser-dynamic": "2.0.0",
    "@angular/router": "3.0.0",
    "core-js": "^2.4.1",
    "rxjs": "5.0.0-beta.12",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "@types/jasmine": "^2.2.30",
    "angular-cli": "1.0.0-beta.16",
    "codelyzer": "~0.0.26",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.9",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "2.0.2"
  }
}

【问题讨论】:

    标签: angular


    【解决方案1】:

    您对所有包运行快速更新并使用更新版本更新 package.json 文件,请按照以下步骤操作

    1. 删除 node_modules 文件夹。
    2. 从 C:\Users\USERNAME\AppData\Roaming 中删除 npm-cache
    3. 打开命令提示符并导航到应用程序的根文件夹。
    4. 使用命令检查 npm 包中的更新

      npm-check-updates -u
      
    5. 使用命令更新所有包并修改你的 package.json 到当前版本

      npm update --save
      

    另外,使用命令全局更新 npm 包

    npm install -g npm-check-updates
    

    希望这能解决您的问题,如果不告诉我。

    【讨论】:

      【解决方案2】:

      [默认] /Users/gdayton/Documents/auction/node_modules/@types/jasmine/index.d.ts:39:45 中的错误:找不到名称“keyof”。

      keyof 是在 Typescript 2.1 中引入的,在你的 package.json 中我看到了 Typescript 2.0.2。我知道您提到您升级了 Typescript,但可能需要更新的版本。

      【讨论】:

      • 嘿,我将 Typescript 更新到 2.2.1,现在出现以下错误:ERROR in ./src/main.ts Module build failed: TypeError: Cannot read property 'exclude' of undefined at applyDefaults (/Users/gdayton/Documents/auction2/node_modules/awesome-typescript-loader/src/instance.ts:266:72)... 我是否正确假设 awesome-typescript-loader 需要旧版本的 Typescript?
      • 是的,加载程序和打字稿版本可能不匹配。这可能很棘手,因为您的软件包之间可能没有兼容的配置——听起来您可能必须升级或降级其中一个软件包才能为所有内容获得可接受的版本。
      猜你喜欢
      • 2017-05-19
      • 2017-04-01
      • 2021-09-29
      • 1970-01-01
      • 2015-02-06
      • 2017-07-30
      • 1970-01-01
      • 1970-01-01
      • 2016-12-14
      相关资源
      最近更新 更多