[英]Using npm installed JS/CSS lib on a Laravel application
I'm actually experimenting with Laravel and npm, and i struggle to use Bootstrap Tags Input lib inside my app (also as any other npm installed lib).我实际上正在尝试使用 Laravel 和 npm,并且我很难在我的应用程序中使用引导标签输入库(也与安装的任何其他 npm 库一样)。
It seems pretty easy but i'm missing something here.这似乎很容易,但我在这里遗漏了一些东西。
λ npm i bootstrap-tagsinput
npm WARN sass-loader@8.0.2 requires a peer of node-sass@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@8.0.2 requires a peer of fibers@>= 3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules\watchpack\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ bootstrap-tagsinput@0.7.1
added 1 package from 2 contributors and audited 1088 packages in 4.143s
found 2 vulnerabilities (1 low, 1 high)
run `npm audit fix` to fix them, or `npm audit` for details
λ npm install
npm WARN sass-loader@8.0.2 requires a peer of node-sass@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@8.0.2 requires a peer of fibers@>= 3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules\watchpack\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
audited 1088 packages in 3.31s
found 2 vulnerabilities (1 low, 1 high)
run `npm audit fix` to fix them, or `npm audit` for details
Inside my /resources/js/app.js file:在我的/resources/js/app.js文件中:
require('bootstrap-tagsinput/src/bootstrap-tagsinput');
I've tried stuff like
window.BootstrapTagsInput = require('bootstrap-tagsinput/src/bootstrap-tagsinput');
我试过像
window.BootstrapTagsInput = require('bootstrap-tagsinput/src/bootstrap-tagsinput');
Did not work any better.没有更好的工作。
Inside my resources/css/app.scss file:在我的resources/css/app.scss文件中:
// 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 :在我的资源/视图/布局/app.blade.php 中:
<div id="app" class="h-100">
<input type="text" value="Amsterdam,Washington,Sydney,Beijing,Cairo" data-role="tagsinput" />
</div>
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
https://i.stack.imgur.com/PXMd4.png https://i.stack.imgur.com/PXMd4.png
https://i.stack.imgur.com/0wZz0.png https://i.stack.imgur.com/0wZz0.png
I've searched the answer to my question on many posts already, but nothing seems to work on my case.我已经在很多帖子上搜索了我的问题的答案,但似乎对我的情况没有任何作用。 Many thanks to anybody who will try to help me on this, really appreciate.
非常感谢任何愿意帮助我的人,非常感谢。
Ok, turns out that the installation process was good, everything is finally working well, sorry for your time.好的,事实证明安装过程很好,一切都运行良好,对不起您的时间。
Why not just use the latest stable version of Bootstrap?为什么不直接使用最新的稳定版 Bootstrap? Your package doesn't seem to be up to date and maintained.
您的 package 似乎不是最新的和维护的。 Bootstrap 5 will be coming out soon.
Bootstrap 5 即将推出。
https://getbootstrap.com/docs/4.5/components/badge/ https://getbootstrap.com/docs/4.5/components/badge/
npm install bootstrap
Turns out that the installation process of the plugin was good, and I simply had a minor issue in my dev environment.原来插件的安装过程很好,我只是在我的开发环境中遇到了一个小问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.