简体   繁体   English

如何在Meteor 1.3中安装带有npm的软件包,以便其他npm库可以要求它

[英]Where do I install a package with npm in Meteor 1.3 so that other npm libraries can require it

I'm trying to get set up with cloudinary in Meteor 1.3 beta, and I'm going for an NPM package right now. 我正试图在Meteor 1.3测试版中设置cloudinary,我现在正在寻找NPM软件包。 I've run in to a larger problem where in one of the package libraries there is a declaration crypto = require('crypto'); 我遇到了一个更大的问题,其中一个软件包库中有一个声明crypto = require('crypto'); Which is fine. 哪个好。 I just installed the crypto package through npm. 我刚刚通过npm安装了加密包。 But the client is still giving me the error Uncaught Error: Cannot find module 'crypto' . 但客户端仍然给我错误Uncaught Error: Cannot find module 'crypto' … any suggestions? … 有什么建议?

Note, both modules are in the same node_modules directory: 注意,两个模块都在同一个node_modules目录中:

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 这是一个Meteor 1.3问题,因为我正在导入npm库

If module A require s 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. 如果模块A require模块B,那么模块B需要在模块A的node_modules目录中可用。这是npm和节点通常做的事情,你可能很熟悉。 It works the same way in meteor 1.3. 它在流星1.3中的工作方式相同。

If you are the developer of module A than you can look at peer dependencies in npm or npm link . 如果您是模块A的开发人员,那么您可以在npm或npm链接中查看对等依赖项 Or you just run npm install in the module and see if that fixes the problem. 或者您只是在模块中运行npm install ,看看是否能解决问题。

The NPM package crypto can only be used on the server side because it's a built-in library of NodeJS. NPM包加密只能在服务器端使用,因为它是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库来创建散列,例如JS Hashes

JS Hashes can be used on the client-side as well as the server-side. JS哈希可以在客户端和服务器端使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM