Cannot find module 'fs'

前端 未结 4 1832
别那么骄傲
别那么骄傲 2021-01-11 12:20

Hello i\'m facing this issue here: Typescript Node.js simplest setup doesn't work -- error TS2307: Cannot find module 'fs'

And i\'ve tried also that sol

4条回答
  •  佛祖请我去吃肉
    2021-01-11 13:09

    I know i'm probably late but i was faceing the same issue. Finally I got a work around if you want to try. In your tsconfig.json add "node_modules/@types/node" in "typeRoots" as you can see in the config bellow:

    {
      "compileOnSave": false,
      "compilerOptions": {
        "baseUrl": "./",
        "outDir": "./dist/out-tsc",
        "sourceMap": true,
        "declaration": false,
        "downlevelIteration": true,
        "experimentalDecorators": true,
        "module": "esnext",
        "moduleResolution": "node",
        "importHelpers": true,
        "target": "es2015",
        "typeRoots": [
          "node_modules/@types",
          "node_modules/@types/node"
        ],
        "lib": [
          "es2018",
          "dom"
        ]
      }
    }
    

提交回复
热议问题