当前位置:  开发笔记 > 编程语言 > 正文

未捕获的ReferenceError:require未在require('./ bootstrap')Laravel Mix中定义

如何解决《未捕获的ReferenceError:require未在require('./bootstrap')LaravelMix中定义》经验,为你挑选了0个好方法。

我使用Laravel Mix编译了我的样式表和javascript文件,代码如下:

const { mix } = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

// mix.js('resources/assets/js/app.js', 'public/js')
//    .sass('resources/assets/sass/app.scss', 'public/css');

mix.babel([
    'public/js/plugins/loaders/pace.min.js',
    'resources/assets/js/app.js',
    'public/js/plugins/loaders/blockui.min.js',
    'public/js/plugins/ui/nicescroll.min.js',
    'public/js/plugins/ui/drilldown.js',
    'public/js/plugins/ui/fab.min.js',
    'public/js/plugins/forms/selects/select2.min.js',
    'public/js/plugins/forms/styling/uniform.min.js',
    'public/js/plugins/ui/moment/moment.min.js',
    'public/js/plugins/ui/fullcalendar/fullcalendar.min.js',
    'public/js/core/app.js',
    'public/js/pages/user_pages_profile.js',
] , 'public/js/app.js');

mix.styles([
    'public/css/icons/icomoon/styles.css',
    'resources/assets/sass/app.scss',
    'public/css/core.css',
    'public/css/components.css',
    'public/css/colors.css',
],'public/css/app.css');


下面是我的app.js

/**
 * First we will load all of this project's JavaScript dependencies which
 * includes Vue and other libraries. It is a great starting point when
 * building robust, powerful web applications using Vue and Laravel.
 */

require('./bootstrap'); //complains on this line after compilation

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */

Vue.component('example', require('./components/Example.vue'));

const app = new Vue({
    el: '#app'
});


它抱怨所需的,
Uncaught ReferenceError:在app.js:354中没有定义require,这是 我尝试过的已编译的app.js
:
1- mix.scripts
2- mix.babel(根据文档,这将翻译任何ES2015代码到所有浏览器都能理解的vanilla JavaScript.)
我在这里缺少什么?

推荐阅读
爱唱歌的郭少文_
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有