Uncaught ReferenceError: require is not defined (javascript)
13,318
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.
Author by
Az Emna
Updated on June 04, 2022Comments
-
Az Emna almost 2 years
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?
-
Get Off My Lawn almost 6 yearshow are you running the file?
node /my/file.js
? -
Get Off My Lawn almost 6 yearsyou don't need
requirejs
when running a node application.require
is built into node, so it sounds like you are not running the file properly.
-
-
desoares almost 6 yearsI 'd like to note for you that I was not the one who voted your answer down.
-
Harshal Yeole almost 6 yearsOk, no worries. :)