npm将web3安装到Appcelerator Titanium SDK中> 6.x [英] npm install web3 into Appcelerator Titanium SDK > 6.x
问题描述
我想将web3
安装到我的移动App项目中.
I would like to install web3
into my mobile App project.
但是,我在访问它时遇到问题,而没有出现很多红色屏幕,说我无法访问其中的这些文件.我试图手动更新路径等;
However I am having issues with accessing it without having a buch of red screens saying I can't access these files within it. I tried to manually update the paths etc;
我所做的是在我的App文件夹中:npm install web3
What I've done is in my App folder: npm install web3
然后我在App目录中看到node_modules
文件夹...但是,我无法通过以下简单方法在我的index.js文件中要求该模块:
Then I see the node_modules
folder in my App directory... however, I am not able to require the module in my index.js file with a simple:
var Web3 = require('web3'); // throws error
var web3 = new Web3();
function doClick(e) {
var version = web3.version.api;
$.label.text = "Web3 version: " + version;
}
$.index.open();
现在,我已将node_modules
中的文件夹粘贴到我在App文件夹下创建的lib
中,并尝试访问其中的dist
以访问web3.min
,然后尝试了很多其他操作,没有运气...还有其他人遇到过这样的问题或解决方案吗?
Now I've pasted the folder from the node_modules
into a lib
I created under App folder, and tried to access the dist
within that to access web3.min
, then tried a whole lot of other things, with no luck... has anybody else had such issue or have a solution?
推荐答案
该模块无法正常工作.从细微差异:
This module isn't going to work. From the Appc Node.js Support doc under minor differences:
SDK不能替代Node的核心模块
SDK doesn't have replacements for Node's core modules
我认为这实际上是一个主要区别,因为许多节点模块或其依赖项使用Node.js核心模块.例如,web3
使用名为XMLHttpRequest
的模块,该模块又使用Node.js核心 url 模块. Titanium将抛出一个错误,提示它找不到模块:体系结构的URL:x86_64".最可能还有其他几个核心模块依赖性.
I think this actually a major difference, as many node modules or their dependencies use Node.js core modules. For example, web3
uses a module called XMLHttpRequest
, which in turn uses the Node.js core url module. Titanium will throw an error saying it 'couldn't find module: url for architecture: x86_64'. There are most likely several other core module dependencies.
至少目前,Node.js支持似乎最适合独立js库.考虑momentjs
或underscore
(尽管它们已经内置在Alloy中).
The Node.js support, at least currently, appears to be best suited for standalone js libraries. Think momentjs
or underscore
(though those are already built-in to Alloy).
这篇关于npm将web3安装到Appcelerator Titanium SDK中> 6.x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!