【问题标题】:Why does VS-Code not Recognize "__dirname"?为什么 VS-Code 不能识别“__dirname”?
【发布时间】:2020-01-19 14:09:58
【问题描述】:

我目前正在开发一个后端项目,我需要从 JSon 文件中读取数据,但 VS Code 无法识别变量“__dirname”。

我尝试了不同的方法来更改我的代码,但都没有奏效。

private ourPathToFile = `${__dirname} ~/Desktop/richwood/dhbw-richie-backend/dhbw-third-semester-training-data/training-data.json`

找不到名称“__dirname”

【问题讨论】:

    标签: typescript backend nestjs


    【解决方案1】:

    你是否安装了节点类型?

    npm i @types/node --save-dev
    yarn add -D @types/node
    

    node types define the global __dirname

    【讨论】:

      猜你喜欢
      • 2014-10-28
      • 2011-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-26
      • 2020-09-08
      • 1970-01-01
      相关资源
      最近更新 更多