0

While trying to use this library I initially got error ReferenceError: require is not defined. To solve it, I added required library. This now started with another error as Module name "crypto" has not been loaded yet for context

FOR LEG PULLERS: This is not a duplicate question, As all the questions are either poorly answered or not answered. I have done my research, EG: this does not tells where to try it. this is unanswered. this does not tells where do I get those paths like 'path/to/filesize' and all other paths anyways if I get then also is useless in my context. this defines a module of its own, I need a predefined "crypto" module. The default google library is not doing the job.

Community
  • 1
  • 1
jeet.chanchawat
  • 5,842
  • 5
  • 38
  • 59
  • You don't need requirejs library, because nodejs has its own require function. You need to figure out why `require is not defined`. Are you trying with node or browser? If second - script by link simply not for this case. – Andrey Feb 20 '17 at 08:08
  • Quick follow up. What's the environment? Node/browser? Version? – Andrey Feb 20 '17 at 08:11
  • I am doing it with JQM. In Firefox-WebIde – jeet.chanchawat Feb 20 '17 at 09:39

1 Answers1

2

From my guessing, you are under browser environment instead of developing a NodeJS app.

This crypto you refer to is actually for back-end (NodeJS), provided as NodeJS API, and also, the require keyword, is a NodeJS one.

And from my knowledge, there is no crypto in the default browser environment, neither is there a require. For most cases, there is a REQUIRE.JS and Browserify that let you use this type of require statement, but for your case, I suggest not to use them.

For crypto used in browser environment, I would suggest something using some third-party libraries, like crypto-js, and you without browserify or bower, you should pay special attention to its Usage without RequireJS section.

Chazeon
  • 546
  • 2
  • 14