6

I’m trying to get set up with cloudinary in Meteor 1.3 beta, and I’m going for an NPM package right now. I’ve run in to a larger problem where in one of the package libraries there is a declaration crypto = require('crypto'); Which is fine. I just installed the crypto package through npm. But the client is still giving me the error Uncaught Error: Cannot find module 'crypto' . … any suggestions?

Note, both modules are in the same node_modules directory:

node_modules
    crypto
    material-ui
    react
    react-cloudinary
    react-dom
    react-mounter
    react-tap-event-plugin

This is particularly a Meteor 1.3 issue since I’m importing npm libraries

Robin Newhouse
  • 2,158
  • 2
  • 19
  • 17

2 Answers2

0

If module A requires module B than module B needs to be available in the node_modules directory of module A. That's the usual thing that npm and node do and that you're probably familiar with. It works the same way in meteor 1.3.

If you are the developer of module A than you can look at peer dependencies in npm or npm link. Or you just run npm install in the module and see if that fixes the problem.

bert
  • 1,556
  • 13
  • 15
  • So each module needs a directory containing each module it depends on? that seems redundant... I suppose then I use `npm install` in the directory of the module giving me trouble? – Robin Newhouse Mar 28 '16 at 21:43
  • Yes try that. It does seem redundant but on the other hand it helps each module to be independent. – bert Mar 29 '16 at 15:52
0

The NPM package crypto can only be used on the server side because it's a built-in library of NodeJS. It's a high-performance library so perhaps it's compiled.

If you can change the code you could instead use a pure js library for creating hashes such as JS Hashes.

JS Hashes can be used on the client-side as well as the server-side.

Lucidity
  • 1,299
  • 17
  • 19