Error while import bootstrap
See original GitHub issueI get an error when I try to import bootstrap. Version: “^4.0.0-beta”,
ERROR in ./~/bootstrap/dist/js/bootstrap.js
Module parse failed:
...\src\main\frontend\node_modules\bootstrap\dist\js\bootstrap.js this.state.current.addBlock is not a function
You may need an appropriate loader to handle this file type.
TypeError: this.state.current.addBlock is not a function
Module file:
import React from 'react';
import ReactDOM from 'react-dom';
import "../style/app.scss";
import "jquery";
import "popper.js";
import "bootstrap";
My webpack:
const PATHS = {
source: path.join(__dirname, 'app'),
output: path.join(__dirname, '../../../target/classes/static')
};
const common = {
entry: [
PATHS.source
],
output: {
path: PATHS.output,
publicPath: '',
filename: 'bundle.js'
},
module: {
loaders: [{
exclude: /node_modules/,
loader: 'babel'
}, {
test: /\.css$/,
loader: 'style!css'
}, {
test: /\.scss$/,
loader: 'style!css!resolve-url-loader!sass'
}, {
test: /\.jpg|png$/,
loader: "file?name=[path][name].[ext]"
},{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
}]
},
resolve: {
extensions: ['', '.js', '.jsx']
},
plugins: [
new webpack.ProvidePlugin({
jQuery: 'jquery',
$: 'jquery',
'window.jQuery': 'jquery',
"Tether": 'tether',
Popper: ['popper.js', 'default']
// In case you imported plugins individually, you must also require them here:
// Util: "exports-loader?Util!bootstrap/js/dist/util",
// Dropdown: "exports-loader?Dropdown!bootstrap/js/dist/dropdown",
})
]
};
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Error: File to import not found or unreadable: ~bootstrap/scss ...
When Sass is precompiled by its own CLI, it processes @imports by itself, and sometimes thus doesn't understand ~ notation.
Read more >bootstrap 5 cant import · Discussion #33570 - GitHub
I got the same error using ES6 and webpack. My loader in webpack.config.js excluded the /node_modules/ . It caused that the bootstrap js...
Read more >Error: File to import not found or unreadable: bootstrap - Drupal
Installed bootstrap in my custom theme. From my custom theme directory, ran npm install bootstrap . This created the "node_modules" folder. I ...
Read more >Bootstrap Import throws Invalid CSS error - Help - Jekyll Talk
I am having an issue with an Invalid CSS error when I try to import TWBS Bootstrap into my bare bones Jekyll project....
Read more >Bootstrap & Vite
Install additional dependency. In addition to Vite and Bootstrap, we need another dependency (Sass) to properly import and bundle Bootstrap's CSS.
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

I’m not sure bootstrap is compatible with React you should use : https://reactstrap.github.io/
It is not a problem with webpack/babel version. Probably ,you have to add loader for css https://getbootstrap.com/docs/4.0/getting-started/webpack/#importing-styles Please also look at the my webpack config