首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >NPM安装不从.js文件重新创建.ts文件。

NPM安装不从.js文件重新创建.ts文件。
EN

Stack Overflow用户
提问于 2016-09-23 10:53:45
回答 2查看 1.9K关注 0票数 1

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

"npm安装“(没有任何警告或错误)

创建node_modules,但不从.js文件中重新创建.ts文件,而角模块不更新。

我的tsconfig.json

代码语言:javascript
运行
复制
{
  "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:

代码语言:javascript
运行
复制
{
  "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启动后

代码语言:javascript
运行
复制
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

在原木上,它永远不会结束。

我能查到什么?

EN

回答 2

Stack Overflow用户

发布于 2016-09-23 10:57:59

npm将只在package.json文件中安装上述软件包。

要生成js代码,需要运行

npm start

它将在监视模式下运行类型记录编译器,并将ts代码转换为js代码。

在这里查看npm start命令所做的工作:

代码语言:javascript
运行
复制
start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" 
票数 1
EN

Stack Overflow用户

发布于 2016-09-23 10:58:11

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

如果在运行npm安装后未显示类型文件夹,则需要使用以下命令手动安装:

代码语言:javascript
运行
复制
npm run typings install

您需要运行npm start

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

  1. 处于监视模式的TypeScript编译器,它将从类型记录转换为javascript。
  2. 名为lite-server的静态文件服务器,它在浏览器中加载index.html并在应用程序文件更改时刷新浏览器。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39659016

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档