Quantcast
Channel: Active questions tagged require - Stack Overflow
Viewing all articles
Browse latest Browse all 153

Uncaught ReferenceError: require is not defined in dist folder

$
0
0

I was doing a short project on real time-chat, everything is working fine in development mode, but when I build the distfolder for deployment,It doesn't work

In my code there is no CommonJS code, as I am only working on only ECMAScript modules. But after building the project I am gettingUncaught ReferenceError: require is not defined.

And I have found that require does exist on my dist folder

require("websocket").w3cwebsocket;var Nw=require("websocket").w3cwebsocket

this is the part which is making error.

So,I tried to get rid of these require as it is showing as a error, But changing after vite.config.js file

  build: {    target: 'modules',  },

So, I don't get require, still it's not working. Can anyone help me with this?


Viewing all articles
Browse latest Browse all 153

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>