So, I'm trying to use node modules with JavaScript and for that, I need to load the modules with "require", so I installed Require.js like so:
npm i requirejs
This is my code:
var ecurve = require('ecurve') ;
var BigInteger = require('bigi')
var AES = require("crypto-js/aes");
var SHA256 = require("crypto-js/sha256");
var CryptoJS = require("crypto-js");
However, I always get this error:
require is not defined
I've tried Browserify and solved the problem but I need another solution without Browserify. Any ideas?
This would help you:
RequireJS is a JavaScript file and module loader. It is optimized for in-browser use, but it can be used in other JavaScript environments, like Rhino and Node. Using a modular script loader like RequireJS will improve the speed and quality of your code.
IE 6+ .......... compatible ✔ Firefox 2+ ..... compatible ✔ Safari 3.2+ .... compatible ✔ Chrome 3+ ...... compatible ✔ Opera 10+ ...... compatible ✔
http://requirejs.org/docs/download.html
Add this to your project: download_me
please go through require.js docs.