编译失败:Angular 5中的./node_modules/macaddress/lib/windows.js [英] Failed to compile : ./node_modules/macaddress/lib/windows.js in Angular 5
问题描述
我是Angular 5的新手,根据我的业务需要,我需要获取用户计算机的 mac 地址.为此,我尝试实现以下内容...
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...
参考: https://www.npmjs.com/package/macaddress >
npm install --save macaddress
我已经使用NPM和以下代码在打字稿文件中添加了此软件包.
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.
./node_modules/macaddress/lib/windows.js 找不到模块:错误:无法解析'D:\ Projects \ Angular \ eCommerceWebsite \ node_modules \ macaddress \ lib'中的'child_process' 错误@ vendor.js:158535
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
在控制台中找到了它.
更新:
推荐答案
您不能从Angular应用程序中使用此库.出于安全原因,您根本无法从浏览器查询用户的mac地址.该库旨在用于服务器端的node.js应用程序,与任何客户端应用程序无关. 在此处了解更多信息
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
这篇关于编译失败:Angular 5中的./node_modules/macaddress/lib/windows.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!