打字稿错误:环境上下文中不允许使用初始化程序

时间:2017-08-08 06:11:24

标签: angular typescript

这里我试图将我的Angular2升级到Angular4我将错误视为严重程序代码描述项目文件行抑制状态 错误构建:环境上下文中不允许使用初始化程序 的 Package.js

{
  "name": "angular-quickstart",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "4.0.0",
    "@angular/compiler": "4.0.0",
    "@angular/core": "4.0.0",
    "@angular/forms": "4.0.0",
    "@angular/http": "4.0.0",
    "@angular/platform-browser": "4.0.0",
    "@angular/platform-browser-dynamic": "4.0.0",
    "@angular/router": "4.0.0",
    "@angular/upgrade": "4.0.0",
    "core-js": "^2.4.1",
    "reflect-metadata": "^0.1.3",
    "rxjs": "^5.0.1",
    "systemjs": "0.19.27",
    "zone.js": "^0.8.4",
    "bootstrap": "^3.3.6"
  },
  "devDependencies": {
    "concurrently": "^2.2.0",
    "lite-server": "^2.2.2",
    "typescript": "^2.0.2",
    "typings": "^1.3.2"
  }
}

2 个答案:

答案 0 :(得分:0)

检查你的打字稿版本。可能你的打字稿已经过时了。使用旧的node_modules时也可能出现同样的问题。请尝试使用更新的节点包

答案 1 :(得分:0)

在终端尝试npm install -g typescript @ latest以获取最新的打字稿。