2016-09-23 80 views
0

我想將我的angular2/typescript文件編譯爲javascript文件。NPM INSTALL不會從.ts文件重新創建.js文件

「故宮安裝」(沒有任何警告或錯誤)

創建node_modules,而不是重新創建的.js文件構成了我.ts文件和角模塊沒有更新。

我tsconfig.json

和的package.json:

{ 
    "name": "angular-quickstart", 
    "version": "1.0.0", 
    "private": true, 
    "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", 
    "angular2-in-memory-web-api": "0.0.20", 
    "bootstrap": "^3.3.6", 
    "core-js": "^2.4.1", 
    "react-redux": "^4.4.5", 
    "reflect-metadata": "^0.1.3", 
    "rxjs": "5.0.0-beta.12", 
    "systemjs": "0.19.27", 
    "zone.js": "^0.6.23", 
    "react-super-components": "^0.3.5", 
    "redux": "^3.5.2", 
    "redux-thunk": "^2.1.0", 
    "param-store":"^1.0.0" 
    }, 
    "devDependencies": { 
    "concurrently": "^2.2.0", 
    "lite-server": "^2.2.2", 
    "typescript": "^2.0.2", 
    "typings": "^1.3.2" 
    } 
} 

NPM啓動後有

1] 16.09.23 14:05:50 404 POST /api/logging 
[1] 16.09.23 14:05:50 404 POST /api/logging 
[1] 16.09.23 14:05:50 404 POST /api/logging 
[1] 16.09.23 14:05:50 404 POST /api/logging 
[1] 16.09.23 14:05:50 404 POST /api/logging 
[1] 16.09.23 14:05:50 404 POST /api/logging 
[1] 16.09.23 14:05:50 404 POST /api/logging 
[1] 16.09.23 14:05:50 404 POST /api/logging 
日誌

,它是永遠不會結束。

我可以檢查什麼?

+0

編譯命令是npm run tsc。在watch模式下編譯命令是npm run tsc:w。在監視模式下,只要保存任何文件,編譯器就會自動編譯所有ts文件。 – ranjeet8082

回答

1

npm install將只提供package.json文件中提到的軟件包。

產生js代碼,你需要運行

npm start

將運行在觀看模式打字稿編譯器和將transpile ts代碼js代碼。

看這裏npm start命令做什麼:

start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" 
+0

是的,我有相同的「開始」命令 – alexey

0

npm install將安裝在的package.json

列出的軟件包如果運行NPM安裝後的分型文件夾顯示不出來,你需要使用命令手動安裝:

npm run typings install 

你需要運行npm start

該命令運行以下兩個平行的節點處理:

  1. 打字稿編譯器在計時模式,這將花費transpiling從打字稿的JavaScript。

  2. 一個名爲lite-server的靜態文件服務器,它在瀏覽器中加載index.html,並在應用程序文件更改時刷新瀏覽器。

+0

對不起,我fogot提到,我使用安裝後npm開始。日誌中有些奇怪:[1] 16.09.23 14:02:28 404 POST/api/logging [1] 16.09.23 14:02:28 404 POST/api/logging [1] 16.09.23 14 :02:28 404 POST/api/logging [1] 16.09。23 14:02:28 404 POST/api/logging [1] 16.09.23 14:02:28 404 POST/api/logging [1] 16.09.23 14:02:28 404 POST/api/logging [ 1] 16.09.23 14:02:28 404 POST/api/logging [1] 16.09.23 14:02:28 404 POST/api/logging [1] 16.09.23 14:02:28 404 POST/api /日誌記錄 ... ... ...並且永不結束 – alexey