'Node ESM await for import() to return?

Is, in the following code, import('crypto') actually await from crypto to load and then return it?

const _module = (async () => {
        try {
            return await import('crypto');
        } catch (e) {
            return window.crypto || window.msCrypto || Math;
        }
    })();

Im pretty confused right now, because _module is a Promise and in my head it should be the Node.js module crypto. What do I do wrong?

Thank you



Solution 1:[1]

import crypto from 'node:crypto' works fine. I was also confused by nodejs doc showing usage with await, but it's not needed.

More info: What is the await keyword effect when importing ESM modules

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marius