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.

Error while import bootstrap

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

16reactions
Johann-Scommented, Sep 16, 2017

I’m not sure bootstrap is compatible with React you should use : https://reactstrap.github.io/

0reactions
leebakecommented, Sep 22, 2017

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

Read more comments on GitHub >

github_iconTop 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 >

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