getMac npm angular cli

638 views Asked by At

I have install this:

npm install --save getmac

and insert in my home.components.ts this code

import getMAC, { isMAC } from 'getmac';

and in ngOnInit this code text:

console.log(getMAC());

The Console Error is:

core.js:5873 ERROR Error: failed to get the MAC address
at getMAC (index.js:37)
at HomeComponent.ngOnInit (home.component.ts:15)
at callHook (core.js:3937)
at callHooks (core.js:3901)
at executeInitAndCheckHooks (core.js:3842)
at refreshView (core.js:11795)
at refreshDynamicEmbeddedViews (core.js:13142)
at refreshView (core.js:11800)
at refreshComponent (core.js:13217)
at refreshChildComponents (core.js:11508)

Where am I wrong?

1

There are 1 answers

0
Developer On

From https://www.npmjs.com/package/getmac?activeTab=readme

Get the MAC address of the current machine you are on.

This library will not run in web browsers / on the client-side / in webpack / in browserify / in angular / in react / in jQuery / in HTML. It will only run on Node.js environments, which the web browser is not.