Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ligonsker's avatar

How to install Bootstrap (5) with Laravel 9?

I followed the following guide:

https://getbootstrap.com/docs/5.2/getting-started/vite/

and I still get all sorts of errors, sometimes file is not found or sometimes I just don't see the bootstrap design.

I installed Bootstrap using npm:

npm install [email protected]

Then I installed scss using npm:

npm i --save-dev sass

Then I added the following to vite.config.js:

resolve: {
    alias: {
        '~bootstrap': path.resolve(__dirname, 'nodes_modules/bootstrap'),
    }
}

Also added the following to /resources/app.js:

import '/resources/scss/styles.scss'    
import * as bootstrap from 'bootstrap';

I also created a new scss folder in /resources and placed the following styles.scss file inside:

// Import all of Bootstrap's CSS
@import "~bootstrap/scss/bootstrap";

But when I use npm run dev or build, the Bootstrap styling don't show up, or I'm getting error about files not existing, for example:

[plugin:vite:css] [sass] ENOENT: no such file or directory, open '/var/www/myapp/nodes_modules/bootstrap/scss/bootstrap

Update: When I change this line:

@import "~bootstrap/scss/bootstrap";

to this:

@import 'node_modules/bootstrap/scss/bootstrap.scss';

It works, any idea why, and will it work as expected?

0 likes
2 replies
Lara_Love's avatar

download it and use it . if i was , i do download or Include via CDN

bhamner's avatar

It's because you have a typo in your alias. Change

'~bootstrap': path.resolve(__dirname, 'nodes_modules/bootstrap'),

to

'~bootstrap': path.resolve(__dirname, 'node_modules/bootstrap'),

Please or to participate in this conversation.