I have facing against an issue provoked by an npm package
which I previouly installed to get the hostname and ip address
in my angular project
, everything is ok in dev mode
but when I build it to get the production files
it doesn't work, I have debugged my project and I noticed that everything fails when I use the method to get the hostname.
Nowadays what I'm doing is printing in console the next code.
I declared the next variable.
declare var require: any;
And I'm using the next code in my ngOnInit()
const os = require('os');
console.log(os.hostname());
In dev mode it works, but in production mode is fails throwinf the next error.
I my package.json
I have the package os
in my dependencies.
"dependencies": {
"os": "^0.1.1",
...
}
Does anyone know why this happen?