Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Missing initializer in const declaration" caused when building minified bundle. #23

Open
mohit-jasapara opened this issue Sep 15, 2018 · 2 comments

Comments

@mohit-jasapara
Copy link

Missing initializer in const declaration error when creating minified build

const networkInterface,length;

Solution:
Replace

if(typeof __webpack_require__ !== 'function'){
    var mac = '', networkInterfaces = require('os').networkInterfaces();
    for(interface_key in networkInterfaces){
        var networkInterface = networkInterfaces[interface_key];
        var length = networkInterface.length;
        for(var i = 0; i < length; i++){
            if(networkInterface[i].mac && networkInterface[i].mac != '00:00:00:00:00:00'){
                mac = networkInterface[i].mac; break;
            }
        }
    }
    address = mac ? parseInt(mac.replace(/\:|\D+/gi, '')).toString(36) : '' ;
}

const networkInterface -> var networkInterface
const length -> var length

@fgeorgsson
Copy link

When running a unit test in Jest that uses uniqid the same problem appears:

Test suite failed to run

    ReferenceError: interface_key is not defined

    > 6 | const uniqid = require('uniqid');

@darrylsepeda
Copy link

I encounter this error when I run test in Jest also,
is there any solution yet regarding this issue?

@mohit-jasapara , does your solution need to be applied on the minified bundle or on uniqid source code before minified?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants