【发布时间】:2019-04-19 17:53:54
【问题描述】:
我的文件夹结构中有一个public.key 和private.key 文件,它没有包含在构建中,即当我运行tsc 时。
我正在使用公钥/私钥对来生成 json Web 令牌。 这就是我导入工作正常并生成令牌的文件的方式。
private publicKey = fs.readFileSync(path.join(__dirname, "../../utils/keys/public.key"), "utf8");
相同的代码适用于 private.key 只是文件名更改。
这是我的tsconfig.json 文件
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": false,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist/",
"pretty": true,
"baseUrl": ".",
"alwaysStrict": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"paths": {
"*": ["node_modules/*", "src/*", "*"]
}
},
"include": ["src/**/**/*.ts"],
"exclude": ["node_modules"]
}
有没有办法让 typescript 包含 *.key 文件?
【问题讨论】:
-
问题缺少stackoverflow.com/help/mcve。您如何使用该文件以及为什么要包含它?
-
@estus 更新了问题以反映相同
-
这可能不是 stackoverflow.com/questions/36690779/typescript-copy-files 的副本,因为 XY 问题。
标签: node.js typescript express typescript-typings tsconfig