gpt4 book ai didi

node.js - 在 Eclipse 中向 Cordova 应用程序添加平台时出错

转载 作者:太空宇宙 更新时间:2023-11-03 22:30:05 25 4
gpt4 key购买 nike

在 Eclipse (Mars) 中创建新的 Cordova 项目后,当我单击“完成”时,它开始向我的应用程序添加平台,但最终抛出以下错误并且未添加平台:

X:\CordovaWorkspace\DemoProject>cordova prepare Discovered platform
"android@5.3.0-nightly.2016.7.6.103e1e8d" in config.xml. Adding it to
the project Adding android project... Running command: cmd "/s /c
"C:\Users\XYZ\.cordova\lib\android\cordova\5.3.0-nightly.2016.7.6.103e1e8d\bin\create.bat

X:\CordovaWorkspace\DemoProject\platforms\android demo.project "Demo
Project" --cli"" module.js:327
throw err;
^

Error: Cannot find module 'sax'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\Users\XYZ\.cordova\lib\android\cordova\5.3.0-nightly.2016.7.6.103e1e8d\node_modules\elementtree\lib\parsers\sax.js:3:11)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17) Error: cmd: Command failed with exit code 1 Error: No platforms added to this project. Please use
`cordova platform add <platform>`.

X:\CordovaWorkspace\DemoProject>exit

enter image description here

如何解决。

最佳答案

尝试通过下载 sax 模块并将其放在名为 sax 的文件夹中来手动解决 sax 要求。

或使用npm install如果您在互联网上找不到 sax mmodule,您可以在 node-elementtree/lib/parsers/sax.js 中创建 sax.js 并将此代码放在下面:

var util = require('util');

var sax = require('sax');

var TreeBuilder = require('./../treebuilder').TreeBuilder;

function XMLParser(target) {
this.parser = sax.parser(true);

this.target = (target) ? target : new TreeBuilder();

this.parser.onopentag = this._handleOpenTag.bind(this);
this.parser.ontext = this._handleText.bind(this);
this.parser.oncdata = this._handleCdata.bind(this);
this.parser.ondoctype = this._handleDoctype.bind(this);
this.parser.oncomment = this._handleComment.bind(this);
this.parser.onclosetag = this._handleCloseTag.bind(this);
this.parser.onerror = this._handleError.bind(this);
}

XMLParser.prototype._handleOpenTag = function(tag) {
this.target.start(tag.name, tag.attributes);
};

XMLParser.prototype._handleText = function(text) {
this.target.data(text);
};

XMLParser.prototype._handleCdata = function(text) {
this.target.data(text);
};

XMLParser.prototype._handleDoctype = function(text) {
};

XMLParser.prototype._handleComment = function(comment) {
};

XMLParser.prototype._handleCloseTag = function(tag) {
this.target.end(tag);
};

XMLParser.prototype._handleError = function(err) {
throw err;
};

XMLParser.prototype.feed = function(chunk) {
this.parser.write(chunk);
};

XMLParser.prototype.close = function() {
this.parser.close();
return this.target.close();
};

exports.XMLParser = XMLParser;

关于node.js - 在 Eclipse 中向 Cordova 应用程序添加平台时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38392562/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com