Nel*_*son 8 node.js typescript
在我的打字稿代码中,我试图访问__dirname全局对象:https://nodejs.org/docs/latest/api/globals.html
我看到编译错误:TS2304:Cannot find name '__dirname'.
我可以毫无问题地运行代码.如何tsc编译没有错误?
Nel*_*son 18
在tsconfig.json加"node"来compilerOptions.types.
例:
{
"compilerOptions": {
...
"types": [
"node"
]
...
}
}
Run Code Online (Sandbox Code Playgroud)
然后跑 npm install @types/node --save-dev
| 归档时间: |
|
| 查看次数: |
6210 次 |
| 最近记录: |