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

My js script uses 'require', which I can't use in browser. Will changing to 'import' fix this and when should I avoid 'require' altogether?

$
0
0

I am setting up a webhook receiver just to learn the ropes. I have run a number of tests that work fine with node. Now I am attempting to put this receiver on a publicly hosted page so that I don't have to keep my personal computer on at all times. But when I open the file in browser I get the error Uncaught ReferenceError: require is not defined. If I just change the "require" lines to "import" will that fix the problem?

Separately, if 'require' can't be used in browser, when is it appropriate and when should I just avoid using it from the start?

I have tried esbuild but that gave me a whole new set of errors and I am wondering if there is a more efficient solution before I go further down that path?


Viewing all articles
Browse latest Browse all 153

Trending Articles



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