我的文件是
import * as fs from 'fs'
async function loadModels() {
console.log('here i am!')
const modelFiles = fs.readFileSync(__dirname + '/models')
console.log(modelFiles)
}
(async () => {
loadModels()
})()
而在 package.json
,我有。
"fixtures": "tsc fixtures/index"
所以当我运行 yarn fixtures
我明白了
yarn fixtures
yarn run v1.22.4
$ tsc fixtures/index
✨ Done in 8.78s.
为什么我的... loadModels
运行?
tsc
只是编译你的TypeScript文件,而不是执行它。
来执行你的TypeScript文件,你可以使用 ts-node
包裹
然后在你 package.json
:
"fixtures": "ts-node fixtures/index"