ScottHamper / Cookies

JavaScript Client-Side Cookie Manipulation Library
The Unlicense
1.77k stars 170 forks source link

Doesn't work. Uncaught TypeError: Cannot read property 'set' of undefined #74

Closed wzup closed 7 years ago

wzup commented 7 years ago

The plugin doesn't work.

npm install --save cookies-js

const Cookies = require('cookies-js')(window);
Cookies.set('foo','bar);

Uncaught TypeError: Cannot read property 'set' of undefined

wzup commented 7 years ago

LOL, I've already posted the error before and even forgot about it https://github.com/ScottHamper/Cookies/issues/70#issue-202037622

So the answer is above. Do not use window if you are using any pre-processors. Require it like that

const Cookies = require('cookies-js');

I use webpack, so it doesn't work with window.