在我的typescript代码中,我试图访问__dirname
全局对象:https://nodejs.org/docs/latest/api/globals.html
我看到一个编译错误:TS2304:Cannot find name '__dirname'.
在我的typescript代码中,我试图访问__dirname
全局对象:https://nodejs.org/docs/latest/api/globals.html
我看到一个编译错误:TS2304:Cannot find name '__dirname'.
在tsconfig.json
中加"node"
到compilerOptions.types
.
例子:
{
"compilerOptions": {
...
"types": [
"node"
]
...
}
}
然后跑npm install @types/node --save-dev