1

angular2/typescript ファイルを javascript ファイルにコンパイルしようとしています。

「npm install」 (警告やエラーなし)

node_modules を作成しますが、私の .ts ファイルから .js ファイルを再作成しません。角度モジュールは更新されません。

私の tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "suppressImplicitAnyIndexErrors": true
  },
  "files": [
  ],
  "exclude": [
    "node_modules",
    "scripts"
  ],
  "compileOnSave": true
}

および 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 START の後に

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

ログにあり、それは決して終わりません。

何を確認できますか?

4

2 に答える 2

1

npm install は、前述のパッケージを package.json ファイルにインストールするだけです。

js実行する必要があるコードを生成するには

npm start

typescript コンパイラを監視モードで実行し、tsコードをjsコードにトランスパイルします。

npm startコマンドが何をするかをここで見てください:

start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" 
于 2016-09-23T10:57:59.173 に答える
0

npm installpackage.json にリストされているパッケージをインストールします

npm install を実行した後、typings フォルダーが表示されない場合は、次のコマンドを使用して手動でインストールする必要があります。

npm run typings install

実行する必要がありますnpm start

このコマンドは、次の 2 つの並列ノード プロセスを実行します。

  1. typescript から javascript へのトランスパイルを行うウォッチモードの TypeScript コンパイラ。

  2. index.html をブラウザーにロードし、アプリケーション ファイルが変更されたときにブラウザーを更新する、lite-server と呼ばれる静的ファイル サーバー。

于 2016-09-23T10:58:11.157 に答える