I get properly credit card info upon input done I called a function to validate credit card with luhn module ( npm install luhn) as I use :
var luhn = requir
require
is not available in the browser. It is used in Node.js.
If you want to use require
on the client side then use Browserify:
Browserify lets you require('modules') in the browser by bundling up all of your dependencies.
In fact, require
couldn't be available in the browser in the form as it is implemented in Node. The problem with require
is that it is synchronous. It works on the server side on the first tick of the event loop when you can block on I/O because no event listeners are bound yet, but it will not work in the browser without problems because it would have to block the UI for the entire time that the modules are downloaded, compiled and run.
In fact synchronous vs asynchronous module loading has been a matter of controversy. See those answers for more details: