JSK*_*JSK 21 javascript node.js typescript
一切都在标题中,试图将我的 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"]
}
Run Code Online (Sandbox Code Playgroud)
在我的 package.json 这是我要编译的脚本:
"scripts": {
"build-ts": "tsc",
"watch-ts": "tsc -w",
},
Run Code Online (Sandbox Code Playgroud)
我的项目结构:
rootdir
|
|-----src
| |----server.ts
| |----app.ts
|-----test
|-----node_modules
|-----typings
|-----config
|-----tsconfig.json
|-----package.json
Run Code Online (Sandbox Code Playgroud)
知道我做错了什么吗?
Ian*_*ane 73
TypeScript 可能无法创建文件夹的另一种情况dist
是,在 中设置"incremental": true
或 时,您删除该文件夹而不删除跟踪增量构建的 。"composite": true
compilerOptions
tsconfig.json
dist
tsconfig.tsbuildinfo
如果您tsconfig.tsbuildinfo
保留并删除或修改dist
,编译器将不需要输出任何内容,因为tsconfig.tsbuildinfo
它告诉它没有任何工作要做。问题是tsconfig.tsbuildinfo
引用旧状态的dist
.
假设您的npm run clean
命令运行rimraf dist
。您还必须将其更新为rimraf tsconfig.tsbuildinfo
.
Rem*_*ing 56
该noEmit
选项会导致 TypeScript 不发出任何文件。您需要在 build-ts 脚本中删除 "noEmit": true 或传递 --noEmit false 。
特别提示:重命名脚本prepack
有npm
编译打字稿你,当你运行npm pack
或npm publish
。
归档时间: |
|
查看次数: |
11892 次 |
最近记录: |