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

Base64 is not defined in Node.js environment #7

Open
CocaCola183 opened this issue Jun 7, 2017 · 7 comments
Open

Base64 is not defined in Node.js environment #7

CocaCola183 opened this issue Jun 7, 2017 · 7 comments

Comments

@CocaCola183
Copy link

JSONC.js:275

return Base64.encode(String.fromCharCode.apply(String, gzip.zip(str,{level:9})));
@CocaCola183
Copy link
Author

may be gzip is not defined too

@sd031
Copy link

sd031 commented Jun 14, 2017

I am getting this issue too in node.js

@ehartford
Copy link

Same here.

/Users/hartbeat/node_modules/jsoncomp/src/JSONC.js:275
    return Base64.encode(String.fromCharCode.apply(String, gzip.zip(str,{level:9})));
           ^

ReferenceError: Base64 is not defined
    at Object.JSONC.pack (/Users/hartbeat/node_modules/jsoncomp/src/JSONC.js:275:12)
    at Object.<anonymous> (/Users/hartbeat/scratch/thing.js:94:33)

@muthmano-dev
Copy link

Any workaround for this ?

@shreychaturvedi123
Copy link

any update on this issue?

@roschler
Copy link

roschler commented May 4, 2018

Hey everyone, it's a little hard to find but you can find it here:

http:https://www.webtoolkit.info/javascript_base64.html#.Wuy0KXXwbCJ

@jamesearl
Copy link

Or you can do something like this, before you try to call a function that depends on these:

global.Base64 = {
  encode: function(str) {
    return Buffer.from(str).toString('base64');
  },
};
global.gzip = {
  zip: function(str) {
    return zlib.gzipSync(Buffer.from(str));
  },
}

Hacky but it gets the job done.

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

7 participants