Browserify doesn't work with os npm module

时间:2018-09-19 08:23:21

标签: javascript npm browserify

I have tried to get the os npm module working in a browser using browserify using the following code snippet:

const osBrowserify = require("os");
const userInfo = osBrowserify.cpus();
Object.entries(userInfo).forEach(([key, value]) => {
    console.log(value, key);     
});

This works on the following website: https://npm.runkit.com/os-browserify

I have installed browserify globally using npm and converted my code into bundle.js without issue. However, when the code is ran using live-server or hosted on netlify, osBrowserify is undefined.

I have also tried using require("os-browserify") (which i have also installed using npm) and still no joy.

Does anyone have any suggestions?

0 个答案:

没有答案