0

With my node(v16.13.2)

const os = require("os");

this is perfectly work.

But

import os from "os";

This gives me an error that Module 'os' has no default export

I don't understand why it is.

And why node is designed like that.

MINJA KIM
  • 876
  • 1
  • 8
  • 22
  • 1
    Why? Because _"Module 'os' has no default export"_. Use `import * as os from "os"` to import the entire thing or only import what you need, eg `import { arch } from "os"` – Phil May 15 '22 at 04:34
  • Does this answer your question? [error TS1192: Module '" A.module"' has no default export](https://stackoverflow.com/questions/40429927/error-ts1192-module-a-module-has-no-default-export) – Phil May 15 '22 at 04:35

1 Answers1

0

you can fix this by saving the file with .mjs extension instead of .js, or by adding { "type": "module" } to your package.json file