The problem is that require is a function provided by node.js's 'module' module. It is not part of the ES5 spec, and so it is not natively available in web browsers.
In order to load modules using require, you will have to use a web bundler (like Webpack, Browserify or RequireJS). This will bundle together all of the JS in your project into a single file, automatically handling calls to require.
The problem is that
require
is a function provided by node.js's 'module' module. It is not part of the ES5 spec, and so it is not natively available in web browsers.In order to load modules using
require
, you will have to use a web bundler (like Webpack, Browserify or RequireJS). This will bundle together all of the JS in your project into a single file, automatically handling calls torequire
.I'd recommend reading Getting started with Webpack to get you on your way.