【发布时间】:2020-03-25 06:20:50
【问题描述】:
给定:
一个带有import 但没有export 调用的ts 模块,名为./sn-ps.ts
一个名为 ./main.ts
的 ts 模块
一个tsconfig如下...
{
"compilerOptions": {
"target": "ESNext",
"module": "commonjs",
"allowJs": true,
"checkJs": true,
"sourceMap": true,
"downlevelIteration": true,
"noImplicitAny": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"baseUrl": ".",
},
"exclude": [
"node_modules"
]
}
问题:
如何在 ./main 模块中导入 ./sn-ps 文件,这样我才能确定 ./sn-ps 是否在 ./main 之前运行?
我尝试了import from "./snippet"; 和import * as arbitrarySymbol from "./snippet"; 以及变体,但没有成功。
【问题讨论】:
标签: node.js typescript module