编译失败:./node_modules/macaddress/lib/windows.js in Angular 5

Failed to compile : ./node_modules/macaddress/lib/windows.js in Angular 5

我是 Angular 5 的新手,根据我的业务需要,我需要获取用户 machine 的 mac address.For 我试图实现以下...

参考:https://www.npmjs.com/package/macaddress

npm install --save macaddress

我已经使用 NPM 添加了这个包,并在我的打字稿文件中添加了以下代码。

var macaddress = require('macaddress'); //added this code below my imports

 ngOnInit() {
    macaddress.one(function (err, mac) {
      console.log("Mac address for this host: %s", mac);  
    });
}

添加此代码后,我无法 运行 我的项目,它显示黑屏并出现上述错误。

谁能帮我解决这个问题。

编辑:./node_modules/macaddress/lib/windows.js 找不到模块:错误:无法解析 'D:\Projects\Angular\eCommerceWebsite\node_modules\macaddress\lib' 中的 'child_process' 错误 @ vendor.js:158535

在控制台中得到这个。

更新:

这是在应用程序模块文件中添加模块的示例 app.module.ts 例如 'BrowserModule'

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent }  from './app.component';

@NgModule({
 imports:      [ BrowserModule ],
 declarations: [ AppComponent ],
 bootstrap:    [ AppComponent ]
})
export class AppModule { }

您不能从 Angular 应用程序使用此库。出于安全原因,您根本无法从浏览器查询用户的 mac 地址。该库适用于服务器端 node.js 应用程序,与任何客户端应用程序无关。 More info here