node-machine-id icon indicating copy to clipboard operation
node-machine-id copied to clipboard

import function not working

Open wiulma opened this issue 5 years ago • 2 comments

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!

wiulma avatar Feb 23 '20 08:02 wiulma

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

PaulKeefe avatar May 14 '20 23:05 PaulKeefe

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

ahm750 avatar Jun 12 '20 20:06 ahm750