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.

Browserify w/ NPM : Uncaught ReferenceError: getCookie is not defined

See original GitHub issue

Hi,

I try to use js-cookie with Browserify and NPM. I check my compiled JS files, js-cookie is inside, everything look fine.

But when I want to use function of js-cookie, I got this error :

Uncaught ReferenceError: getCookie is not defined

Am I doing something wrong ?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
gchudnovcommented, Sep 22, 2016

You’re welcome!

1reaction
gchudnovcommented, Sep 22, 2016

Guess, you should import the library, like this:

var Cookies = require('js-cookie');

or if you use ES6 with babel + browserify, you can use import:

import Cookies from 'js-cookie'

and later:

var value = Cookies.get('KEY');
OR
const value = Cookies.get('KEY'); // ES6
Read more comments on GitHub >

github_iconTop Results From Across the Web

Getcookie not defined - jquery - Stack Overflow
Solved, needed to specify this: function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.
Read more >
js-cookie - npm
A simple, lightweight JavaScript API for handling cookies. Latest version: 3.0.1, last published: a year ago. Start using js-cookie in your ...
Read more >
Node.js Notes for Professionals
not a liated with o cial Node.js group(s) or company(s). ... Section 10.5: Extended project definition ... Section 47.1: /w Express,...
Read more >
getCookie | API Reference - Nightwatch.js
Retrieve a single cookie visible to the current page. The cookie is returned as a cookie JSON object, as defined here. Uses cookie...
Read more >
cookie-parser-browserify - npm package - Snyk
Create a new cookie parser middleware function using the given secret and options . secret a string or array used for signing cookies....
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