Incorporating a JS/CSS library installed via npm into a Laravel application

I am currently exploring the world of Laravel and npm, and I am facing challenges in integrating the Bootstrap Tags Input library into my application (just like any other npm-installed library).

It appears to be straightforward, but I seem to be overlooking something.

Here's what I have done:

Installed dependencies

λ npm i bootstrap-tagsinput

npm WARN [email protected] requires a peer of node-sass@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of fibers@>= 3.1.0 but none is installed. You must install peer dependencies yourself.
...
λ npm install

npm WARN [email protected] requires a peer of node-sass@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of fibers@>= 3.1.0 but none is installed. You must install peer dependencies yourself.
...

Linked the library to my source files

In my /resources/js/app.js file :

require('bootstrap-tagsinput/src/bootstrap-tagsinput');

I've tried different approaches like

window.BootstrapTagsInput = require('bootstrap-tagsinput/src/bootstrap-tagsinput');
, but it didn't yield better results.

In my resources/css/app.scss file :

// Bootstrap-tagsinput
@import '~bootstrap-tagsinput/src/bootstrap-tagsinput.css';
@import '~bootstrap-tagsinput/src/bootstrap-tagsinput-typeahead.css';

In my resources/views/layout/app.blade.php :

<div id="app" class="h-100">
    <input type="text" value="Amsterdam,Washington,Sydney,Beijing,Cairo" data-role="tagsinput" />
</div>

Compiled the code

npm run watch

 DONE  Compiled successfully in 4475ms                                                                                                                                                                                                                                                                             12:39:08 AM

       Asset     Size   Chunks             Chunk Names
/css/app.css  179 KiB  /js/app  [emitted]  /js/app
  /js/app.js  1.4 MiB  /js/app  [emitted]  /js/app

Outcome

Current state

https://i.sstatic.net/PXMd4.png

Expected result:

https://i.sstatic.net/0wZz0.png

Summary

I have extensively searched for solutions to my issue on various platforms, but nothing seems to work in my scenario. A huge thank you to anyone who attempts to assist me with this, your help is truly appreciated 🙏.

Update

Alright, it turns out that the installation process was successful, everything is now functioning correctly. Apologies for taking up your time 🙏.

Answer №1

Have you considered updating to the most recent stable version of Bootstrap? It appears that your current package is outdated and possibly not being actively maintained. Keep in mind that Bootstrap 5 may be released soon.

https://getbootstrap.com/docs/4.5/components/badge/

npm install bootstrap

Answer №2

It appears that the plugin installation went smoothly, with only a small hiccup in my development environment.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Use Javascript to display an image based on the date, otherwise hide the div

I'm looking to implement an image change on specific dates (not days of the week, but actual calendar dates like August 18th, August 25th, September 3rd, etc). Here's the div I'm working with: <div id="matchday"> <img id="home ...

Is hard coding permissions in the frontend considered an effective approach?

I'm in the process of creating an inventory management system that allows admin users to adjust permissions for other employees. Some permissions rely on others to function properly, and I need to display different names for certain permissions on the ...

What is the best way to create a global variable using jQuery?

Is it possible to pass the value of a_href = $(this).attr('href'); function globally and set a_href as "home"? var a_href; $('click a').on('hover', function(e){ a_href = $(this).attr('href'); ...

Resolving Text Animation Flickering Issues in CSS and React

After successfully creating this animation using CSS animations and React, I encountered a flickering issue. The cause of this problem is unclear to me, it could be due to my usage of setInterval or potential issues with the keyframes in my CSS animations. ...

What is the reason for bcrypt's requirement of both C++ and Python?

It has come to my attention that the node.js package for bcrypt relies on various non-Javascript libraries such as C++, Python 2.7, and more. I am curious as to why this is required. Is there a specific reason why encryption necessitates the use of non-Ja ...

Developing a compressed file in JavaScript

async purchaseMultiple(decoded, purchaseData){ const user = await Database.user.findOne({where: { id_user: decoded.id_user }}); if( ! user) return [404, 'ERROR: User [' + decoded.id_user + '] not found']; if(user.credi ...

Learning to transform EST time data into local time within JavaScript utilizing moment.js and Date objects

The recorded date and time is "03/19/2020 13:15:00" in Eastern Standard Time (EST). When attempting to convert it to the local timezone, I have tried various methods, such as using moment.js to change the format from 'MM/DD/YYYY HH:mm:ss' to UT ...

The text does not display on the screen as expected

I attempted to create a calculator using vue.js. Unfortunately, I encountered an issue where the second string value does not get appended on the calculator screen upon clicking the next button. This problem arose after implementing some logic for arithmet ...

How can Ajax assist in utilizing a JavaScript variable within a Rails call that is made within a JavaScript function?

I'm facing a challenge where I need to update a Ruby on Rails partial within a view using a JavaScript object-defined variable, but I'm struggling to make it work. Despite my research pointing towards using an Ajax call as the only viable solutio ...

What is the best way to create a scroll animation that moves vertically or horizontally?

I currently have this code that loads all the comments and displays them within a <p> tag as the video progresses. The style of the newsticker is square with a border line. I would like to show the comment sliding in and then out, similar to the ex ...

What could be causing this to come back as untrue? (MongoDB)

I am facing an issue with my data returning false in this code snippet. Despite having a console log statement, it indicates that there is no data available. I am specifically looking for a document containing the 'userId', which is the identifie ...

What causes additional colors to be introduced into mapbox-gl layers when using setPaintProperty with fill-color and stops?

Currently, I am in the process of creating a data-driven choropleth map for a specific US state using mapbox-gl. The issue at hand is that even though I have defined only three colors in my stops, the map is displaying more than three colors. My assumption ...

Arrange moving shapes in the same spot

Every time I press the button, a unique shape is generated. These shapes are dynamic and can range from polygons to circles (there are hundreds of shapes). Each shape is composed of a series of lines. The problem arises when each shape is positioned diff ...

Leveraging composer to enhance the organization of my dependencies

As I organize my files for my PHP-based website, I've turned to composer for assistance. One issue I've encountered is loading front-end dependencies like jquery into my pages, specifically the index.php. In the past, I manually specified each js ...

What's the optimal method for implementing a Windows-style selection mode in JavaScript?

In Windows, you have the ability to select a folder by clicking on it once. Currently, I am using Vuejs. I am interested in coding the same functionality with multiple arrays retrieved from my database and displayed using v-for. My idea is to add a new c ...

Tips on how to retrieve an Observable Array instead of a subscription?

Is there a way to modify this forkJoin function so that it returns an observable array instead of a subscription? connect(): Observable<any[]> { this.userId = this.authService.userId; this.habits$ = this.habitService.fetchAllById(this.userId); this.s ...

What is the best way to refresh the content of an iframe when a link within the iframe is clicked?

In the code below, I am resizing the iframe based on its content: <html> <head> <title></title> </head> <body> <iframe src="http://page.html" id="iframeid" width="600" height="700" scrolling="n ...

Ways to prompt a specific text value to generate varied responses

Whenever I try to input the letter "h", I expect a specific value in return but for some reason, it's not working as intended. Despite my best efforts to troubleshoot the issue, I have been unsuccessful in finding a solution. It's frustrating bec ...

Having trouble sending data to a Django function with Ajax request

I am currently facing an issue with my AJAX calls in Django. While fetching data works seamlessly, adding new data is resulting in an error message. Method Not Allowed (POST): /mymodels/ Method Not Allowed: /mymodels/ [17/Mar/2020 22:27:24] "POST /mymodel ...

Tweak margins similar to Microsoft Word

Trying to replicate the unique margin-adjustment style found in Microsoft Word. You can change one side of the margin individually without affecting the other side. An example is shown below: Imagine I have a "paper" element that contains a div with some ...