4

I want to include bootstrap into my main.ts so that in _Layout.cshtml I wouldn't need to write

<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>

just leave

<script src="~/bundle/bundle.js" asp-append-version="true"></script>

When I add bootstrap (4.0.0-beta) in main.ts like this:

require("bootstrap");

I get an error in a console output

Error: Bootstrap dropdown require Popper.js (https://popper.js.org)

I installed popper:

npm install popper

and added it into the plugin section, so it looks like

plugins: [
            new CleanWebpackPlugin([bundleFolder]),
            new webpack.ProvidePlugin({
                $: node_dir + "/jquery",
                jQuery: node_dir + "/jquery",
                'window.$': node_dir + '/jquery',
                Popper: ['popper.js', 'default']
            })
        ]

but got another webpack-script error:

ERROR in ./node_modules/bootstrap/dist/js/bootstrap.js Module not found: Error: Can't resolve 'popper.js' in 'D:\Projects\TestApp\TestApp.Web\node_modules\bootstrap\dist\js' @ ./node_modules/bootstrap/dist/js/bootstrap.js 1:0-20 @ ./app/main.ts

Currently I have no idea how to fix it.

3
  • 1
    Please, double check the spelling in the question title. :) Commented Sep 7, 2017 at 22:13
  • @R.Richards haha :"-) done! Commented Sep 7, 2017 at 22:17
  • the plugins was what I was missing... so I found the answer in your question, thanks! Commented Apr 6, 2019 at 6:06

1 Answer 1

14

It appeared that I need popper.js, not popper. So to fix it:

npm install popper.js
Sign up to request clarification or add additional context in comments.

1 Comment

Oh man, I spend way to much time before finding this. Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.