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.

TypeError: undefined is not an object (evaluating 'global.bootstrap = {}')

See original GitHub issue

Hello,

I’m using gulp to process my assets for production.

image

When I process my js files via babel (both v6 and v7) bootstrap throws the following error on the browser:

TypeError: undefined is not an object (evaluating 'global.bootstrap = {}')

image

When I remove the following code from gulp, then bootstrap works fine again…

.pipe(babel({
    presets: ['@babel/env']
}))

but since I’m bundling the files, I have few files written in ES6, thus I really need babel.

Currently, as a workaround, I have bootstrap placed in a separated file, but I would prefer to have it bundled.

The issue for some reason is here:

https://github.com/twbs/bootstrap/blob/976aad0059a22ec1251646a1b4a9f3454c7aed64/dist/js/bootstrap.bundle.js#L9

I’m not sure why when bootstrap passed via babel the global.bootstrap is undefined.

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
panosrucommented, May 29, 2018

@Johann-S Thank you for letting me know that pass Bootstrap through babel isn’t a good idea!

I ended up using gulp-if package and now I pass through babel only the scripts from my “allow” list:

.pipe(gulpif(function (file) {
    // Pass through babel:
    return [
        'my-custom-script'
    ].includes(file.stem);
}, babel({
    presets: ['@babel/env']
})))
0reactions
joakimriedelcommented, Jun 9, 2018

@panosru just ran into the same issue. In the original Bootstrap code this is sent in the IIFE as the argument for global. After babel compiles the file, this will be replaced with undefined. As to why, I do not have a clue and will try your solution to exclude Bootstrap in my gulp script. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: undefined is not an object (evaluating '_this ...
In short, I'm looking to link my camera feed to the mediapipe canvas and display output on it. Error: TypeError: undefined is not...
Read more >
undefined is not an object (evaluating 'phantomArgs.forEach')
I get the following error: TypeError: undefined is not an object (evaluating 'phantomArgs.forEach;). E:\CasperJs\bin\bootstrap.js:48 in global code.
Read more >
JavaScript · Bootstrap
js is a basic helper for transitionEnd events as well as a CSS transition emulator. It's used by the other plugins to check...
Read more >
27/3 - TypeError: undefined is not an object (evaluating 'family ...
Here's the message: TypeError: undefined is not an object (evaluating 'family[i].name') The code outputs the right values to the console, ...
Read more >
TypeError: undefined is not an object - Laracasts
This is the error message: [Error] [Vue warn]: Error in created hook: "TypeError: undefined is not an object (evaluating 'wind.
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