簡體   English   中英

Angular2 打字稿錯誤?

[英]Angular2 typescript error?

我正在嘗試按照https://angular.io/docs/ts/latest/quickstart.html設置我的機器進行角度開發

我已經到了必須運行“npm start”才能真正啟動我的網站的地步,但似乎打字稿編譯失敗了。

tsc 版本:3.10.8 節點版本:6.6.0

> tsc

node_modules/@angular/common/src/localization.d.ts(4,1): error TS1128: Declaration or statement expected.
node_modules/@angular/common/src/localization.d.ts(4,16): error TS1005: ';' expected.
node_modules/@angular/common/src/localization.d.ts(4,25): error TS1005: ';' expected.
node_modules/@angular/common/src/localization.d.ts(5,14): error TS1005: '=' expected.
node_modules/@angular/common/src/localization.d.ts(5,37): error TS1005: ',' expected.
node_modules/@angular/common/src/localization.d.ts(5,43): error TS1005: ';' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(28,1): error TS1128: Declaration or statement expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(28,16): error TS1005: ';' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(28,25): error TS1005: ';' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(29,14): error TS1005: '=' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(29,31): error TS1109: Expression expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(29,41): error TS1005: ';' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(30,14): error TS1005: '=' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(30,41): error TS1005: ',' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(30,50): error TS1005: ';' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(31,14): error TS1005: '=' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(31,29): error TS1005: ',' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(31,41): error TS1005: ',' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(31,54): error TS1005: ',' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(31,75): error TS1005: ',' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(31,84): error TS1005: ';' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(32,14): error TS1005: '=' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(32,32): error TS1005: ',' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(32,44): error TS1005: ',' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(32,57): error TS1005: ',' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(32,78): error TS1005: ',' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(32,87): error TS1005: ';' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(33,14): error TS1005: '=' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(33,23): error TS1005: ';' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(34,14): error TS1005: '=' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(34,20): error TS1005: ';' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(35,14): error TS1005: '=' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(35,27): error TS1005: ',' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(35,52): error TS1005: ';' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(36,14): error TS1005: '=' expected.
node_modules/@angular/common/src/location/location_strategy.d.ts(36,27): error TS1005: ';' expected.
node_modules/@angular/common/src/location/platform_location.d.ts(34,1): error TS1128: Declaration or statement expected.
node_modules/@angular/common/src/location/platform_location.d.ts(34,16): error TS1005: ';' expected.
node_modules/@angular/common/src/location/platform_location.d.ts(34,25): error TS1005: ';' expected.
node_modules/@angular/common/src/location/platform_location.d.ts(35,14): error TS1005: '=' expected.
node_modules/@angular/common/src/location/platform_location.d.ts(35,34): error TS1005: ';' expected.
node_modules/@angular/common/src/location/platform_location.d.ts(36,14): error TS1005: '=' expected.
node_modules/@angular/common/src/location/platform_location.d.ts(36,27): error TS1005: ',' expected.
node_modules/@angular/common/src/location/platform_location.d.ts(36,52): error TS1005: ';' expected.
node_modules/@angular/common/src/location/platform_location.d.ts(37,14): error TS1005: '=' expected.

.... continues


node_modules/zone.js/lib/zone.ts(1110,89): error TS1134: Variable declaration expected.
/mnt/c/Users/mgj/Documents/makeitbro-angular2/node_modules/tsc/bin/tsc.js:11654
                node = node.parent;
                           ^

TypeError: Cannot read property 'parent' of undefined
    at appendOuterTypeParameters (/mnt/c/Users/mgj/Documents/makeitbro-angular2/node_modules/tsc/bin/tsc.js:11654:28)
    at getOuterTypeParametersOfClassOrInterface (/mnt/c/Users/mgj/Documents/makeitbro-angular2/node_modules/tsc/bin/tsc.js:11670:20)
    at getDeclaredTypeOfClassOrInterface (/mnt/c/Users/mgj/Documents/makeitbro-angular2/node_modules/tsc/bin/tsc.js:11807:43)
    at getDeclaredTypeOfSymbol (/mnt/c/Users/mgj/Documents/makeitbro-angular2/node_modules/tsc/bin/tsc.js:11876:24)
    at getTypeFromClassOrInterfaceReference (/mnt/c/Users/mgj/Documents/makeitbro-angular2/node_modules/tsc/bin/tsc.js:12579:24)
    at getTypeFromTypeReference (/mnt/c/Users/mgj/Documents/makeitbro-angular2/node_modules/tsc/bin/tsc.js:12631:48)
    at checkTypeReferenceNode (/mnt/c/Users/mgj/Documents/makeitbro-angular2/node_modules/tsc/bin/tsc.js:16757:24)
    at checkSourceElement (/mnt/c/Users/mgj/Documents/makeitbro-angular2/node_modules/tsc/bin/tsc.js:18585:28)
    at checkSignatureDeclaration (/mnt/c/Users/mgj/Documents/makeitbro-angular2/node_modules/tsc/bin/tsc.js:16575:21)
    at checkFunctionLikeDeclaration (/mnt/c/Users/mgj/Documents/makeitbro-angular2/node_modules/tsc/bin/tsc.js:17153:13)

npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.6.0
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! angular2-quickstart@1.0.0 start: `tsc && concurrently "npm run tsc:w" "npm run lite" `
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular2-quickstart@1.0.0 start script 'tsc && concurrently "npm run tsc:w" "npm run lite" '.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular2-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tsc && concurrently "npm run tsc:w" "npm run lite"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular2-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular2-quickstart
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /mnt/c/Users/mgj/Documents/makeitbro-angular2/npm-debug.log

我的packages.json:

{
  "name": "angular2-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": "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",
    "@angular/upgrade": "2.0.0",
    "core-js": "^2.4.1",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.12",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.23",
    "angular2-in-memory-web-api": "0.0.20",
    "bootstrap": "^3.3.6"
  },
  "devDependencies": {
    "concurrently": "^2.2.0",
    "lite-server": "^2.2.2",
    "typescript": "^2.0.2",
    "typings": "^1.3.2"
  }
}

在 npm install 命令之后,您的項目中應該有typings 文件夾。
如果沒有,請嘗試以管理員身份運行 npm install。

您可以使用以下命令手動安裝類型:

npm run typings install

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM