'加密' node.js模块:无法找到包主错误的包主文件

时间:2015-04-06 17:52:18

标签: node.js cryptography node-modules

我已将加密模块(npm install crypto)安装到我的node.js项目中,但是当我启动应用程序时出现此错误:

Error: Cannot find package main file for package: /opt/PropertyFinder/node_modules/crypto
    at DependecyGraph.resolveDependency (/opt/PropertyFinder/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:199:13)
    at /opt/PropertyFinder/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:117:22
    at Array.forEach (native)
    at collect (/opt/PropertyFinder/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:115:25)
    at /opt/PropertyFinder/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:130:9
    at Array.forEach (native)
    at collect (/opt/PropertyFinder/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:115:25)
    at /opt/PropertyFinder/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:130:9
    at Array.forEach (native)
    at collect (/opt/PropertyFinder/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:115:25)
    at /opt/PropertyFinder/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:130:9
    at Array.forEach (native)
    at collect (/opt/PropertyFinder/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:115:25)
    at /opt/PropertyFinder/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:130:9
    at Array.forEach (native)
    at collect (/opt/PropertyFinder/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:115:25)
[7:40:11 PM] <START> request:/index.ios.bundle

这是什么意思?我在哪里找到该包的主文件?

2 个答案:

答案 0 :(得分:1)

也许您打算使用Node.js&#39;内置crypto模块。

如果是这样,您不需要通过npm进行安装,并且只能在代码中require('crypto')

(首先使用npm uninstall crypto删除&#34;重复&#34;。)

答案 1 :(得分:0)

该错误表示该项目未包含输入脚本。它通常没有index.js or another "main" script specified来允许包。

var crypto = require('/opt/PropertyFinder/node_modules/crypto');

它只包含两个松散的模块,md5.jssha1.js,您必须单独要求:

var md5 = require('/opt/PropertyFinder/node_modules/crypto/md5');
var sha1 = require('/opt/PropertyFinder/node_modules/crypto/sha1');