编译失败:./node_modules/macaddress/lib/windows.js in Angular 5 [英] Failed to compile : ./node_modules/macaddress/lib/windows.js in Angular 5

查看:20
本文介绍了编译失败:./node_modules/macaddress/lib/windows.js in Angular 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Angular 5 的新手,根据我的业务需要,我需要获取用户机器的 ma​​c 地址.为此,我尝试实现以下...

参考:

解决方案

你不能在 Angular 应用中使用这个库.出于安全原因,您根本无法从浏览器查询用户的 mac 地址.该库用于服务器端 node.js 应用程序,与任何客户端应用程序无关.点击此处了解更多信息

I am new to Angular 5 ,as per my business need I need to get the user machine's mac address.For that I tried to implement the following...

Reference: https://www.npmjs.com/package/macaddress

npm install --save macaddress

I have added this package using NPM and the following code in my typescript file .

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);  
    });
}

After adding this codes I can't run my project and it showing a black screen with the above error .

Can anyone help me to fix this please.

Edit : ./node_modules/macaddress/lib/windows.js Module not found: Error: Can't resolve 'child_process' in 'D:\Projects\Angular\eCommerceWebsite\node_modules\macaddress\lib' errors @ vendor.js:158535

got this in console.

Update :

解决方案

You can't use this library from an Angular app. You can't query the user's mac address from a browser at all for security reasons. That library is intended for server-side node.js apps and has nothing to do with any client-side app's. More info here

这篇关于编译失败:./node_modules/macaddress/lib/windows.js in Angular 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆