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:



	], 'public/js/app.js')

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

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


Can you post all the text of the error?

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

Clicking marks the component code:

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.


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’,
message: ‘’
if(this.message.length !=0){

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