【发布时间】:2020-03-22 03:49:43
【问题描述】:
全部在标题中,试图将我的 TypeScript 项目编译到 ./bin 文件夹,tsc 命令执行没有错误导致没有创建任何内容,不知道为什么。
我的 tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"checkJs": false,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"lib": ["es6", "es7", "dom", "esnext"],
"module": "commonjs",
"moduleResolution": "node",
"noEmit": true,
"noImplicitAny": false,
"outDir": "bin",
"removeComments": true,
"sourceMap": true,
"target": "es2017",
"rootDirs": ["src/", "config/"],
"typeRoots": ["./node_modules/@types", "./typings"]
},
"include": ["src/**/*", "./typings"],
"exclude": ["node_modules", "bin", "**/__mocks__*", "**/*.spec.**", "test", "assets"]
}
在我的 package.json 中,这是我要编译的脚本:
"scripts": {
"build-ts": "tsc",
"watch-ts": "tsc -w",
},
我的项目结构:
rootdir
|
|-----src
| |----server.ts
| |----app.ts
|-----test
|-----node_modules
|-----typings
|-----config
|-----tsconfig.json
|-----package.json
知道我做错了什么吗?
【问题讨论】:
-
从最明显的开始:您是否有权在该目录中创建文件夹?外壳中的任何错误?当您在提示符下直接运行
tsc时会发生什么?浏览一下您的配置,它似乎没问题。 -
当我运行命令时,它执行时没有错误
-
您需要在您的
build-ts脚本中删除"noEmit": true或传递--noEmit false -
@RemcoHaszing 是的,就是这样 :) 谢谢,如果你写了答案,我会投票
标签: javascript node.js typescript