【问题标题】:Importing nodejs `fs` with typescript when executing with ts-node?使用ts-node执行时使用打字稿导入nodejs`fs`?
【发布时间】:2017-10-05 03:29:12
【问题描述】:

我正在尝试使用ts-node 运行以下代码。

import { writeFileSync, readFileSync } from 'fs';

但是我得到:

src/main/ts/create.ts (1,45): Cannot find module 'fs'. (2307)

我需要做什么才能让 typescript 导入 fs 模块?

【问题讨论】:

    标签: node.js typescript typescript2.2 ts-node


    【解决方案1】:

    你需要运行:

    $ npm install @types/node --save-dev
    

    如果您需要更多信息,可以参考NodeJS QuickStart in the TypeScript Deep Dive by Basarat

    【讨论】:

      猜你喜欢
      • 2019-10-11
      • 2020-12-06
      • 1970-01-01
      • 1970-01-01
      • 2017-08-20
      • 2021-07-23
      • 2022-07-24
      • 2021-08-31
      • 1970-01-01
      相关资源
      最近更新 更多