Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript - how to import 'os' module

I'm learning Typescript. To do this, I'm building a basic utility app with Node for myself. For this app, I need to use Node's OS Module. My question is, how do I import this module?

In my Typescript file, I have the following:

import { os } from 'os';

This line generates the error: "Cannot find module 'os'". What am I missing?

like image 653
Some User Avatar asked Jul 09 '18 18:07

Some User


1 Answers

Just to update this entry:

import * as os from 'os';

and later, you can use:

const hostname = os.hostname();
like image 105
Arturo Castro Avatar answered Oct 04 '22 06:10

Arturo Castro