Dinesh_dev's avatar

Uncaught ReferenceError: require is not defined laravel 5.4.36

Uncaught ReferenceError: require is not defined How to fix this? my node version is v10.15.0 my npm version is 6.4.1

I tried to fix npm broken packages by fix command, still its not fixing.

Can somebody tell me solution . Thanks in advance.

0 likes
2 replies
bobbybouwmann's avatar

Can you show some code? It seems that you try to use require on some place but it's not working correctly. Do you have a vue component? Just regular javascript? We need more information to help you further!

Also deleting the node_modules directory and installing everything might work as well. But I think this is a code issue

Dinesh_dev's avatar

default app.js code


/**
 * 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');

/**
 * 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'
});

the error pointing here

I also tried with deleting npm folder and installing new , still problem persist

Please or to participate in this conversation.