我已将加密模块(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
这是什么意思?我在哪里找到该包的主文件?
答案 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.js
和sha1.js
,您必须单独要求:
var md5 = require('/opt/PropertyFinder/node_modules/crypto/md5');
var sha1 = require('/opt/PropertyFinder/node_modules/crypto/sha1');