TypeError: undefined is not an object (evaluating 'global.bootstrap = {}')
See original GitHub issueHello,
I’m using gulp to process my assets for production.

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 = {}')

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:
I’m not sure why when bootstrap passed via babel the global.bootstrap is undefined.
Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Johann-S Thank you for letting me know that pass Bootstrap through babel isn’t a good idea!
I ended up using
gulp-ifpackage and now I pass through babel only the scripts from my “allow” list:@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.