2016-05-26 92 views
0

我也一步步角的引導: https://angular.io/guide/quickstart`NPM install`返回一個錯誤

而當我到步驟的npm install

我得到這個錯誤:

[email protected] MINGW64 ~/Documents/angular2 
$ npm install 

> [email protected] postinstall C:\Users\morwin\Documents\angular2 
> typings install 

typings ERR! message Unable to connect to "https://api.typings.org/entries/dt/node/tags/4.0.0%2B20160509154515" 
typings ERR! caused by unable to verify the first certificate 

typings ERR! cwd C:\Users\morwin\Documents\angular2 
typings ERR! system Windows_NT 6.1.7601 
typings ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\morwin\\Documents\\angular2\\node_modules\\typings\\dist\\bin.js" "install" 
typings ERR! node -v v6.1.0 
typings ERR! typings -v 0.8.1 
typings ERR! code EUNAVAILABLE 

typings ERR! If you need help, you may report this error at: 
typings ERR! <https://github.com/typings/typings/issues> 

npm WARN optional Skipping failed optional dependency /chokidar/fsevents: 
npm WARN notsup Not compatible with your operating system or architecture: [email protected] 
npm WARN [email protected] No description 
npm WARN [email protected] No repository field. 
npm ERR! Windows_NT 6.1.7601 
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" 
npm ERR! node v6.1.0 
npm ERR! npm v3.8.6 
npm ERR! code ELIFECYCLE 
npm ERR! [email protected] postinstall: `typings install` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script 'typings install'. 
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 package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  typings install 
npm ERR! You can get information on how to open an issue for this project with: 
npm ERR!  npm bugs angular2 
npm ERR! Or if that isn't available, you can get their info via: 
npm ERR!  npm owner ls angular2 
npm ERR! There is likely additional logging output above. 

npm ERR! Please include the following file with any support request: 
npm ERR!  C:\Users\morwin\Documents\angular2\npm-debug.log 

所以我試圖繼續npm start

而我得到:

[email protected] MINGW64 ~/Documents/angular2 
$ npm start 

> [email protected] start C:\Users\morwin\Documents\angular2 
> tsc && concurrently "npm run tsc:w" "npm run lite" 

node_modules/@angular/core/src/application_ref.d.ts(39,88): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/application_ref.d.ts(99,42): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/application_ref.d.ts(174,33): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(24,15): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(26,16): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/di/reflective_provider.d.ts(105,123): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/di/reflective_provider.d.ts(105,165): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/async.d.ts(27,33): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/async.d.ts(28,45): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/collection.d.ts(1,25): error TS2304: Cannot find name 'MapConstructor'. 
node_modules/@angular/core/src/facade/collection.d.ts(2,25): error TS2304: Cannot find name 'SetConstructor'. 
node_modules/@angular/core/src/facade/collection.d.ts(4,27): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(4,39): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(7,9): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(8,30): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(11,43): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(12,27): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(14,23): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(15,25): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(100,41): error TS2304: Cannot find name 'Set'. 
node_modules/@angular/core/src/facade/collection.d.ts(101,22): error TS2304: Cannot find name 'Set'. 
node_modules/@angular/core/src/facade/collection.d.ts(102,25): error TS2304: Cannot find name 'Set'. 
node_modules/@angular/core/src/facade/lang.d.ts(4,17): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/lang.d.ts(5,17): error TS2304: Cannot find name 'Set'. 
node_modules/@angular/core/src/facade/lang.d.ts(70,59): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/promise.d.ts(2,14): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(8,32): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(9,38): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(10,35): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(10,93): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(11,34): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(11,50): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(12,32): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(12,149): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(13,43): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/linker/component_resolver.d.ts(8,53): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/linker/component_resolver.d.ts(12,44): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(62,148): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(103,144): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(108,139): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(109,135): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/reflection/reflector.d.ts(28,22): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/reflection/reflector.d.ts(30,15): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/reflection/reflector.d.ts(32,15): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/reflection/reflector.d.ts(34,15): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/reflection/reflector.d.ts(36,16): error TS2304: Cannot find name 'Set'. 
node_modules/@angular/core/src/testability/testability.d.ts(40,20): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/platform-browser-dynamic/platform_browser_dynamic.d.ts(75,90): error TS2304: Cannot find name 'Promise'. 
node_modules/rxjs/Observable.d.ts(10,66): error TS2304: Cannot find name 'Promise'. 
node_modules/rxjs/Observable.d.ts(66,60): error TS2304: Cannot find name 'Promise'. 
node_modules/rxjs/Observable.d.ts(66,70): error TS2304: Cannot find name 'Promise'. 

npm ERR! Windows_NT 6.1.7601 
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" 
npm ERR! node v6.1.0 
npm ERR! npm v3.8.6 
npm ERR! code ELIFECYCLE 
npm ERR! [email protected] start: `tsc && concurrently "npm run tsc:w" "npm run lite" ` 
npm ERR! Exit status 2 
npm ERR! 
npm ERR! Failed at the [email protected] 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 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 
npm ERR! Or if that isn't available, you can get their info via: 
npm ERR!  npm owner ls angular2 
npm ERR! There is likely additional logging output above. 

npm ERR! Please include the following file with any support request: 
npm ERR!  C:\Users\morwin\Documents\angular2\npm-debug.log 

我該怎麼做才能使它工作?

+0

它看起來像你的npm拒絕類型包的證書。所有其他錯誤都是由於缺少類型而產生的。嘗試運行此命令以禁用嚴格的證書驗證:'npm config set strict-ssl false',然後再次嘗試'npm install'。 – awiseman

+0

謝謝。但我得到這個錯誤:https://gist.github.com/morwin10/d430b0f3c7513b2b7aee47fce11a77bd –

+0

你可以發佈你的package.json嗎? – awiseman

回答

2

在用戶目錄

C:\Users\morwin創建一個文件名.typingsrc - 爲例如

包含:

{ 
    "rejectUnauthorized": false, 
    "registryURL": "http://api.typings.org/" 
} 

這就是所有

它現在的作品!

+0

這對我沒有用,但是我確實使用這個package.json : –

+0

配置在這裏爲我工作:[鏈接](https://github.com/KevinRaffay/Angular2Sandbox) –

0

也許你沒有正確複製所有文件,是最容易克隆GitHub上的項目,如:

git clone ./my-angular-app https://github.com/angular/quickstart 

是最完整的,和樂於助人的一個例子。

+0

我之前試過了,它沒有幫助 –

+0

你得到了同樣的錯誤?,你是否已經安裝了globaly TypeScrip編譯器? – Koronos

+0

我做了Angular的指導。我應該安裝哪個編譯器? –

6

由於無法驗證第一個證書而導致的第一個錯誤。 它看起來像一個打字代理問題。創建一個名爲.typingsrc的文件並將其放在您的主目錄中。

.typingsrc:

{ 
    "proxy": "http://<proxyURI>:<port>", 
    "rejectUnauthorized": false 
} 

第二個錯誤 「無法找到名爲 '承諾'。」 (等)

在你tsconfig.json文件, 「compilerOptions」 讓 「目標」 下: 「ES6」

"compilerOptions": { 
    "outDir": "app", 
    "target": "es6", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": false, 
    "suppressImplicitAnyIndexErrors": true 
} 
+0

我應該填寫什麼? 我不認爲我在代理上,因爲我檢查了我的路由器ip(在10.0.0.138 ..)和whatismyip.com,並且它是相同的ip地址 –

+0

如果您不在代理後面,請刪除該行。 – Xeno

+0

我只有第二個問題(「無法找到名字'Promise'。」(等)),並將目標從「es5」更改爲「es6」。我想知道爲什麼AngularJs教程提供了「es5」的目標呢? – jdebon