Mar*_*Nuc 5 node.js typescript
当我将 NodeJS 与 Typescript 一起使用时,它允许我使用 NodeJS 中的模块(如fs),尽管我没有安装@types/node.
为什么?它们是以某种方式被烘烤的吗?
它确实需要@types/node:
echo "import * fs fs from 'fs';" > test.ts
tsc test.ts
Run Code Online (Sandbox Code Playgroud)
结果是
test.ts:1:21 - error TS2307: Cannot find module 'fs'.
1 import * as fs from 'fs';
Run Code Online (Sandbox Code Playgroud)
然后做一个
npm install @types/node
tsc test.ts
Run Code Online (Sandbox Code Playgroud)
运行良好。
您是否可能在全球范围内安装了@types/node?
| 归档时间: |
|
| 查看次数: |
5647 次 |
| 最近记录: |