node-machine-id
node-machine-id copied to clipboard
import function not working
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!
I had to do the same thing. const ClientUtility = require('node-machine-id'); let machId = ClientUtility.machineIdSync(true);
As @PaulKeefe mentioned, you have to use require('node-machine-id') instead of "import".