我正在一个由 Tomcat 托管的项目中编写 Angular 2 代码。我现在添加一些 Angular 2 代码。
我使用了 quickstart使用实时监视编译器的项目。这意味着它会在检测到更改时编译 ts
文件。
不过,现在所有的项目都是由Tomcat托管的。那么,如何编译 ts
文件呢?手动?
每次代码更改都按build project
?
我看到 package.json
包括这个:
"name": "angular2-quickstart",
"version": "1.0.0",
"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"
},
但是当我运行的时候
➜ angular2 git:(push_n) ✗ npm tsc:w
Usage: npm <command>
where <command> is one of:
access, adduser, bin, bugs, c, cache, completion, config,
ddp, dedupe, deprecate, dist-tag, docs, edit, explore, get,
help, help-search, i, init, install, install-test, it, link,
list, ln, logout, ls, outdated, owner, pack, ping, prefix,
prune, publish, rb, rebuild, repo, restart, root, run,
run-script, s, se, search, set, shrinkwrap, star, stars,
start, stop, t, tag, team, test, tst, un, uninstall,
unpublish, unstar, up, update, v, version, view, whoami
更新
我听从了 Supun 的指示
现在我得到:
➜ tsc -w /Users/eladb/WorkspaceQa/SupporTool/src/main/webapp/html/angular2/*
error TS6053: File '/Users/eladb/WorkspaceQa/SupporTool/src/main/webapp/html/angular2/app.ts' not found.
error TS6053: File '/Users/eladb/WorkspaceQa/SupporTool/src/main/webapp/html/angular2/node_modules.ts' not found.
error TS6053: File '/Users/eladb/WorkspaceQa/SupporTool/src/main/webapp/html/angular2/typings.ts' not found.
error TS6054: File '/Users/eladb/WorkspaceQa/SupporTool/src/main/webapp/html/angular2/index.html' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
error TS6054: File '/Users/eladb/WorkspaceQa/SupporTool/src/main/webapp/html/angular2/package.json' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
error TS6054: File '/Users/eladb/WorkspaceQa/SupporTool/src/main/webapp/html/angular2/pushResult.html' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
error TS6054: File '/Users/eladb/WorkspaceQa/SupporTool/src/main/webapp/html/angular2/styles.css' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
error TS6054: File '/Users/eladb/WorkspaceQa/SupporTool/src/main/webapp/html/angular2/systemjs.config.js' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
error TS6054: File '/Users/eladb/WorkspaceQa/SupporTool/src/main/webapp/html/angular2/tsconfig.json' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
error TS6054: File '/Users/eladb/WorkspaceQa/SupporTool/src/main/webapp/html/angular2/typings.json' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
11:45:17 PM - Compilation complete. Watching for file changes.
但是我更改了文件,控制台中没有显示任何日志
最佳答案
按照这些步骤应该没问题,
- 在 Windows 中使用终端或命令提示符全局安装 tscw(从任何地方)-> npm install -g tscw
- 然后,在命令提示符下键入 tsc(仅“tsc”- 不需要“npm tsc”或),并验证输出。你应该得到这样的东西。
- 现在您可以从列出的操作集中执行您想要的操作,并且可以包含参数(如果有的话)。
关于macos - 如何使用 Tomcat 运行 Angular 2 形式的 IntelliJ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39022197/