How to find module “fs” in VS Code with TypeScript?

前端 未结 6 1852
一生所求
一生所求 2021-01-30 12:17

I\'m running on a MacBook Air. I installed VS Code as an IDE and also have TypeScript installed.

I have a simple file with just this line:

import fs = req         


        
6条回答
  •  野性不改
    2021-01-30 13:02

    All you need is "moduleResolution" set to "node" in your tsconfig.json:

    {
      "compilerOptions": {
          ...
          "moduleResolution": "node"
          ...
      }
    }
    

    execute

    npm install @types/node --save-dev
    

    and now you can use standard TypeScript import:

    import * as fs from "fs";
    

提交回复
热议问题