【问题标题】:Typescript initialization error when compiling编译时打字稿初始化错误
【发布时间】:2017-10-11 22:36:06
【问题描述】:

在 IntelliJ-Idea 2017.1.1 IDE 中遇到 TypeScript 错误

我尝试过启用 JavaScript、NodeJS 和 TypeScript 编译器。

我已经尝试了一切,但没有得到修复,我可能错过了某个地方。

错误:初始化错误(打字稿)。无法读取属性'createHash of undefined

谁能帮我解决?

package.json

{
  "name": "TempPractice",
  "version": "0.0.1",
  "description": "First Angular App",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "git@github.com:angularjs-de/angularjs-typescript-seed.git"
  },
  "main": "app/app.ts",
  "scripts": {
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "typings": "typings",
    "postinstall": "typings install",
    "update-deps": "npm update",
    "postupdate-deps": "bower update",
    "prestart": "npm install",
    "start": "http-server -a localhost -p 8000 -c-1 ./app",
    "pretest": "npm install",
    "test": "karma start karma.conf.js",
    "test-single-run": "karma start karma.conf.js --single-run",
    "preupdate-webdriver": "npm install",
    "update-webdriver": "webdriver-manager update",
    "preprotractor": "npm run update-webdriver",
    "protractor": "protractor e2e-tests/protractor.conf.js",
    "update-index-async": "node -e \"var fs=require('fs'),indexFile='app/index-async.html',loaderFile='app/bower_components/angular-loader/angular-loader.min.js',loaderText=fs.readFileSync(loaderFile,'utf-8').split(/sourceMappingURL=angular-loader.min.js.map/).join('sourceMappingURL=bower_components/angular-loader/angular-loader.min.js.map'),indexText=fs.readFileSync(indexFile,'utf-8').split(/\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/).join('//@@NG_LOADER_START@@\\n'+loaderText+'    //@@NG_LOADER_END@@');fs.writeFileSync(indexFile,indexText);\""
  },
  "dependencies": {
    "@angular/common": "^4.4.4",
    "@angular/compiler": "^4.4.4",
    "@angular/core": "^4.4.4",
    "@angular/forms": "^4.4.4",
    "@angular/http": "^4.4.4",
    "@angular/platform-browser": "^4.4.4",
    "@angular/platform-browser-dynamic": "^4.4.4",
    "@angular/router": "^4.4.4",
    "angular-in-memory-web-api": "^0.5.0",
    "angular-route": "^1.6.6",
    "bootstrap": "^3.3.7",
    "font-awesome": "^4.7.0",
    "rxjs": "^5.4.3",
    "ts-node": "^3.3.0",
    "typescript": "^2.5.3",
    "typings": "^2.1.1",
    "zone.js": "^0.8.18"
  }
}

tsconfig.json

  {
     "compilerOptions": {
        "module": "system",
        "removeComments": true,
        "preserveConstEnums": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "sourceMap": true,
        "inlineSources": true,
        "target": "es5"

     },
     "compileOnSave": false,
     // Points folders and file to exclude
     "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
     ]
  }

typings.json

  {  
     "ambientDependencies": {  
        "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd",  
        "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd"  
     }  
  }  

【问题讨论】:

  • InitialiSation error 这似乎不是一个真正的错误。您究竟在何时何地观察到此错误?
  • 当我创建 main.ts 文件时
  • 或任何 TypeScript 文件
  • 我已经在我的问题帖子中添加了错误屏幕截图。请看
  • 尝试以下操作:1)关闭IDE; 2) 完全删除node_modules 目录; 3) 运行npm install; 4)重新打开你的IDE; 5) 测试.ts 文件现在是否可以工作。

标签: angularjs json typescript intellij-idea package.json


【解决方案1】:

您使用的 TypeScript 版本 (2.5.3) 与 2017.1.1 中提供的 TypeScript 服务集成不兼容。该问题是由服务 API (https://github.com/Microsoft/TypeScript/issues/15433) 中的重大更改引起的。

WEB-26641 在 2017.1.3 中得到修复,因此它兼容所有 TypeScript 版本,最高 2.4。 但是 2.5.x 增加了更多的重大变化。因此,如果您需要将 IDEA 与 TypeScript 2.5.3 一起使用,请确保更新到最新的 IDEA 版本。

【讨论】:

    猜你喜欢
    • 2017-06-26
    • 2017-11-16
    • 1970-01-01
    • 1970-01-01
    • 2016-08-21
    • 2018-06-01
    • 1970-01-01
    • 2016-09-09
    • 1970-01-01
    相关资源
    最近更新 更多