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

Uncaught ReferenceError: basket is not defined #174

Open
mzhangx opened this issue Jan 6, 2017 · 1 comment
Open

Uncaught ReferenceError: basket is not defined #174

mzhangx opened this issue Jan 6, 2017 · 1 comment

Comments

@mzhangx
Copy link

mzhangx commented Jan 6, 2017

I am trying to use basket.js in one of my client side projects and seeing the following errors in console after bundling the app in webpack.

Importing the module on top of the app.

import basketjs from 'basket.js';
console.log(basketjs);

Building the above 2 lines test application.

npm run build:dev

Error message in console

Uncaught ReferenceError: basket is not defined
    at application_bundle.js:356
    at Object.<anonymous> (application_bundle.js:358)
    at __webpack_require__ (application_bundle.js:30)
    at Object.<anonymous> (application_bundle.js:73)
    at __webpack_require__ (application_bundle.js:30)
    at Object.<anonymous> (application_bundle.js:62)
    at __webpack_require__ (application_bundle.js:30)
    at application_bundle.js:50
    at application_bundle.js:53
    at webpackUniversalModuleDefinition (application_bundle.js:7)

Why?

The problem is that the basket variable(dependency) can't be found by webpack, it requests to be defined in advanced of implementation.

Solution

Updating line 204 to the following code snippet, so the rest basket.something can be successfully invoked.

var basket = window.basket = {
....

May I submit a PR?

karlicoss added a commit to karlicoss/basket.js that referenced this issue Nov 5, 2020
@karlicoss
Copy link

If someone else has the same problem, and would like to use the NPM version instead of maintaining their own fork, here's how you can patch it with webpack: karlicoss/promnesia@de5ae3a

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

2 participants