Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use @types/node in node application

I am working in VSCode on Ubuntu 16.04. I've created node project using below commads:

npm init
tsc --init

I've created a new file called index.ts. I'm trying to use fs and readling to read file contents. but when I am writing below lines of code at the top of index.d.ts:

import fs = require('fs');
import readline =  require('readline');

I'm getting below error: can not find module 'fs' and can not find module 'readline'

even process is not found. I've installed typings of node from here using below command:

sudo npm install @types/node -global --save

Can anyone please help me how to resolve this error?

like image 250
Pratik Gaikwad Avatar asked Sep 16 '16 21:09

Pratik Gaikwad


1 Answers

Since TypeScript 2.x, all typings are installed using npm like this: npm install @types/node.

like image 187
jfmercer Avatar answered Oct 03 '22 04:10

jfmercer