2016-03-01 48 views
3

我似乎無法使用npm run ts「命令編譯我的手稿 我發現有點奇怪的是,我可以運行npm start並且以這種方式編譯並運行良好。Angular 2測試版「npm run tsc」命令失敗

日誌低於:

0 info it worked if it ends with ok 
1 verbose cli [ 'node', '/usr/local/bin/npm', 'run', 'tsc' ] 
2 info using [email protected] 
3 info using [email protected] 
4 verbose run-script [ 'pretsc', 'tsc', 'posttsc' ] 
5 info pretsc [email protected] 
6 info tsc [email protected] 
7 verbose unsafe-perm in lifecycle true 
8 info [email protected] Failed to exec tsc script 
9 verbose stack Error: [email protected] tsc: `tsc` 
9 verbose stack Exit status 2 
9 verbose stack  at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:213:16) 
9 verbose stack  at EventEmitter.emit (events.js:110:17) 
9 verbose stack  at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14) 
9 verbose stack  at ChildProcess.emit (events.js:110:17) 
9 verbose stack  at maybeClose (child_process.js:1015:16) 
9 verbose stack  at Process.ChildProcess._handle.onexit (child_process.js:1087:5) 
10 verbose pkgid [email protected] 
11 verbose cwd /Users/kasperlaursen/adnexio.frontend 
12 error Darwin 15.3.0 
13 error argv "node" "/usr/local/bin/npm" "run" "tsc" 
14 error node v0.12.7 
15 error npm v2.11.3 
16 error code ELIFECYCLE 
17 error [email protected] tsc: `tsc` 
17 error Exit status 2 
18 error Failed at the [email protected] tsc script 'tsc'. 
18 error This is most likely a problem with the MyProject package, 
18 error not with npm itself. 
18 error Tell the author that this fails on your system: 
18 error  tsc 
18 error You can get their info via: 
18 error  npm owner ls MyProject 
18 error There is likely additional logging output above. 
19 verbose exit [ 1, true ] 

tsconfig.json:

{ 
    "compilerOptions": { 
    "target": "es5", 
    "module": "system", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": false, 
    "outDir": "./bin" 
    }, 
    "exclude": [ 
    "node_modules" 
    ] 
} 

的package.json:

{ 
    "name": "MyProject", 
    "version": "1.0.0", 
    "scripts": { 
    "tsc": "tsc", 
    "tsc:w": "tsc -w", 
    "lite": "lite-server", 
    "start": "concurrent \"npm run tsc:w\" \"npm run lite\" " 
    }, 
    "license": "ISC", 
    "dependencies": { 
    "angular2": "2.0.0-beta.3", 
    "systemjs": "0.19.6", 
    "es6-promise": "^3.0.2", 
    "es6-shim": "^0.33.3", 
    "reflect-metadata": "0.1.2", 
    "rxjs": "5.0.0-beta.0", 
    "zone.js": "0.5.11" 
    }, 
    "devDependencies": { 
    "concurrently": "^1.0.0", 
    "lite-server": "^2.0.1", 
    "typescript": "^1.7.5" 
    } 
} 
+0

請問您可以從package.json分享您的腳本嗎? – Brocco

+0

當然,我把它添加到帖子。我之前忘了它。謝謝 – Habber

+0

請運行'node_modules/.bin/tsc'併發布結果,這樣可以更容易地看到'tsc'產生的錯誤以及它可能失敗的原因 – Brocco

回答

2

您可能使用「npm install」安裝您的依賴關係。這意味着他們不在路上。這就是爲什麼直接使用tsc命令不起作用的原因。

當使用「npm run start」時,我懷疑可以同時使用從node_modules文件夾中使用類似腳本(及其tsc命令)等庫的路徑。

> $(npm bin)/tsc 

詳情請參見這個問題:使用這樣的當

類似 「$(NPM斌)」 確實

這篇文章也可以您感興趣:

+0

即使我得到錯誤: 'node_modules/angular2/src/facade/promise.d.ts(1,10):錯誤TS2661:無法重新導出未在模塊中定義的名稱.' – Habber