NPM INSTALL不会从.ts文件重新创建.js文件

时间:2023-01-18 00:16:50

I am trying to compile my angular2/typescript files to javascript files.

我正在尝试将我的angular2 / typescript文件编译为javascript文件。

"npm install" (without any warnings or errors)

“npm install”(没有任何警告或错误)

creates node_modules, but not recreates .js files form my .ts files and angular modules does not updates.

创建node_modules,但不从我的.ts文件重新创建.js文件,并且角度模块不会更新。

My 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
}

and 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"
  }
}

after NPM START there is

在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

in log and it's never ends.

在日志中,它永远不会结束。

What can i check?

我能检查什么?

2 个解决方案

#1


1  

npm install will just install the mentioned packages in package.json file.

npm install将在package.json文件中安装提到的包。

to generate js code you need to run

生成需要运行的js代码

npm start

which will run typescript compiler in watch mode and will transpile ts code to js code.

这将在监视模式下运行typescript编译器,并将ts代码转换为js代码。

look here what npm start command does:

看看这里npm start命令的作用:

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

#2


0  

npm install will install the packages listed in package.json

npm install将安装package.json中列出的软件包

If the typings folder doesn't show up after running npm install, you'll need to install it manually with the command:

如果在运行npm install后没有显示typings文件夹,则需要使用以下命令手动安装它:

npm run typings install

You need to run npm start

你需要运行npm start

This command runs the following two parallel node processes:

此命令运行以下两个并行节点进程:

  1. The TypeScript compiler in watch mode which will take of transpiling from typescript to javascript.

    处于监视模式的TypeScript编译器,它将从typescript转换为javascript。

  2. A static file server called lite-server that loads index.html in a browser and refreshes the browser when application files change.

    一个名为lite-server的静态文件服务器,它在浏览器中加载index.html,并在应用程序文件更改时刷新浏览器。

#1


1  

npm install will just install the mentioned packages in package.json file.

npm install将在package.json文件中安装提到的包。

to generate js code you need to run

生成需要运行的js代码

npm start

which will run typescript compiler in watch mode and will transpile ts code to js code.

这将在监视模式下运行typescript编译器,并将ts代码转换为js代码。

look here what npm start command does:

看看这里npm start命令的作用:

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

#2


0  

npm install will install the packages listed in package.json

npm install将安装package.json中列出的软件包

If the typings folder doesn't show up after running npm install, you'll need to install it manually with the command:

如果在运行npm install后没有显示typings文件夹,则需要使用以下命令手动安装它:

npm run typings install

You need to run npm start

你需要运行npm start

This command runs the following two parallel node processes:

此命令运行以下两个并行节点进程:

  1. The TypeScript compiler in watch mode which will take of transpiling from typescript to javascript.

    处于监视模式的TypeScript编译器,它将从typescript转换为javascript。

  2. A static file server called lite-server that loads index.html in a browser and refreshes the browser when application files change.

    一个名为lite-server的静态文件服务器,它在浏览器中加载index.html,并在应用程序文件更改时刷新浏览器。