[SOLVED] Meteor 1.5: Buffer is not defined


Updated to 1.5…
And now this error in my console. I found this issue 8645
I installed buffer, tried to add line global.Buffer = global.Buffer || require("buffer").Buffer; in different places, before all imports. But without success.

What I have to do more?


Rolled back to ))))-:


Yeah, they removed Buffer, and some packages expect it to be available, so they crash. I don’t know if you can fix it in your own code, the packages need to be updated.


I think I will do the same. :frowning:


Who are “they”?! In my case error in meteor-node-stubs


Many sorries to @benjamn
I created exactly <app_path>/client/lib/init.js and now it’s working…


From the 1.5 release notes:

Modules in node_modules directories will no longer automatically have access to the Buffer polyfill on the client, since that polyfill contributed more than 22KB of minified JavaScript to the client bundle, and was rarely used. If you really need the Buffer API on the client, you should now obtain it explicitly with require(“buffer”).Buffer.

Unable to load plugin meteor

I was getting this error due to simpl-schema and resolved it by adding this code in my client startup:

global.Buffer = function() {}
global.Buffer.isBuffer = () => false


Alternatively, this is a great spot to switch over to dynamic imports, and do

import('buffer').then(({Buffer}) => {global.Buffer = Buffer;})

I’m fairly certain this should work. I haven’t tested it yet.


I tested it but it is not working.


meteor npm update
so meteor-node-stubs updates


Same problem, none of the above is working. I also installed buffer via npm.

I´ve put the code above of the main file of my client code.


You have to put the code exactly to <app_path>/client/lib/init.js