Laravel8使用webpack报错的解决方法
2533
Laravel8使用webpack报错的解决方法。ERROR in ./node_modules/vue-baberrage/dist/vue-baberrage.js 1:78-95.Module not found: Error: Can't resolve 'timers' in '/www/swooleItem/labarrage/node_modules/vue-baberrage/dist'
Vue-Baberrage
用它来做弹幕比较容易,那么安装后启动时报错了错误,如下:
Compiled with some errors in 2.69s ERROR in ./node_modules/vue-baberrage/dist/vue-baberrage.js 1:78-95 Module not found: Error: Can't resolve 'timers' in '/www/swooleItem/labarrage/node_modules/vue-baberrage/dist' BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it. If you want to include a polyfill, you need to: - add a fallback 'resolve.fallback: { "timers": require.resolve("timers-browserify") }' - install 'timers-browserify' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "timers": false }
对于这个错误,大概的知道是webpack的原因,但为什么报错,我就不知道了。我所有使用的版本是Laravel8。
一,安装
npm install vue-baberrage
二,使用
位置:resources/js/app.js
import { vueBaberrage } from 'vue-baberrage' Vue.use(vueBaberrage)
三,启动时编译错误
npm run dev # 报错,如上
解决方法
第一步:编辑webpack.mix.js
const mix = require('laravel-mix'); mix.js('resources/js/app.js', 'public/js') .vue() .sass('resources/sass/app.scss', 'public/css') // 新增如下配置 .webpackConfig(require('./webpack.config')); ~
第二步:创建wepack.config.js,并编辑如下内容
module.exports = { resolve: { fallback: { "timers": false }, fallback: { "timers": require.resolve("timers-browserify") } } };
第三步:npm install
第四步:npm run dev
至此,问题解决
本文网址:https://www.zztuku.com/index.php/detail-13793.html
站长图库 - Laravel8使用webpack报错的解决方法
申明:本文转载于《自如初博客》,如有侵犯,请 联系我们 删除。
您还没有登录,请 登录 后发表评论!
提示:请勿发布广告垃圾评论,否则封号处理!!