how to avoid Uncaught ReferenceError
问题 I have the below module export in my javascript file, so that I can access it from node.js based build setup (grunt, require..). .... if(module && module.exports) { module.exports = m; } when I use the same file in browser, it gives error Uncaught ReferenceError: module is not defined const.js:49 (anonymous function) I do not use node as backend. how can I avoid this error? That is, I need to export m so that require it during build (node based), but works standalone in browser. why doesn't