question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebPack / Require usage

See original GitHub issue

Installed js-cookie via npm, required it inside my asset with require('js-cookie'); but always getting a ReferenceError: Cookies is not defined error when using Cookies.

Am I missing something? I’m using a webpack workflow for my project.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

14reactions
ddlaatcommented, Dec 12, 2017

Add this to your webpack.config:

plugins: [
        new webpack.ProvidePlugin({ Cookies: 'js-cookie/src/js.cookie.js' }),
    ]

It makes js-cookie.js globally available as ‘Cookies’ for other libraries.

8reactions
isharovcommented, Oct 27, 2016

var Cookies = require(‘js-cookie’);

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module Methods - webpack
require (dependency: String);. Synchronously retrieve the exports from another module. The compiler will ensure that the dependency is available in the output ...
Read more >
Using webpack to use require modules in browser
I've tried to run it with this: webpack ./main.js -o bundle.js Yet it still doesn't work. How can this be resolved? javascript ...
Read more >
Getting Started With Webpack - Smashing Magazine
webpack is a highly extensible and configurable static module bundler for JavaScript applications. With its extensible nature, you can plug in ...
Read more >
Webpack: Import vs Require, and why | by Jake Carson Zerrer
Second, if you have configured Webpack to make use of Babel, you need to ensure Babel doesn't try to convert import statements to...
Read more >
Webpack: When To Use And Why - Andy Ray's Blog
Webpack lets you use require() in your source code to point to local files, like images, and decide how they're processed in your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found