Laravel and vue: require is not defined

Hello, does anyone know why in the version of laravel 6 does this problem happen with vue?

the error points to:

require('./bootstrap');

Webpack.mix.js:

mix.scripts([
	'resources/js/jquery-3.4.1.js',
	'resources/js/bootstrap.min.js',
	'resources/js/toastr.js',
	'resources/js/vue.js',
	'resources/js/axios.js',
	'resources/js/app.js'
	], 'public/js/app.js')
	.styles([
	'resources/css/bootstrap.min.css',
	'resources/css/toastr.css'

	], 'public/css/app.css');

It works fine for me but it doesn’t allow me to add components. Any ideas

Hi

Can you post all the text of the error?

Hi,
In the console tells me:
app.js:24703 Uncaught ReferenceError: require is not defined
at app.js:24703

Clicking marks the component code:
require(’./bootstrap’);

Also another thing that I notice is that this error disables me vue devtools.
The code is newly installed, both the Laravel and Vue project and if I create a new project I get the same error.

/**

  • 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’);

window.Vue = require(‘vue’);

/**

  • The following block of code may be used to automatically register your
  • Vue components. It will recursively scan this directory for the Vue
  • components and automatically register them with their “basename”.
  • Eg. ./components/ExampleComponent.vue ->
    */

// const files = require.context(’./’, true, /.vue$/i)
// files.keys().map(key => Vue.component(key.split(’/’).pop().split(’.’)[0], files(key).default))

Vue.component(‘message’, require(’./components/message.vue’).default);

/**

  • 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.
    */

const app = new Vue({
el: ‘#app’,
data:{
message: ‘’
},
methods:{
send(){
if(this.message.length !=0){
console.log(this.message);
}
}
}
});

As require is a Nodejs method, have you checked that everything is working with Node on your system?

Yes. Update the node version. In addition the commands npm install, npm run dev, y watch work correctly