automation-stack / node-machine-id

Unique machine (desktop) id (no admin privileges required)
MIT License
582 stars 62 forks source link

import function not working #44

Open wiulma opened 4 years ago

wiulma commented 4 years ago

Hi! I'm using your code, but I get this error

import {machineIdSync} from 'node-machine-id';

        ^^^^^^^^^^^^^
SyntaxError: The requested module 'node-machine-id' does not provide an export named 'machineIdSync'

In order to make it working, I import the module and then use default object to call exported function:

import ClientUtility from 'node-machine-id';
...
ClientUtility.machineIdSync({original: true})

My environment is node 13, so I'm using modules. Is it possibile to import without default, or this is the right way to use it? Thanks!

PaulKeefe commented 4 years ago

I had to do the same thing. const ClientUtility = require('node-machine-id'); let machId = ClientUtility.machineIdSync(true);

ahm750 commented 4 years ago

As @PaulKeefe mentioned, you have to use require('node-machine-id') instead of "import".