Error: Cannot find module '../node_modules/xml2js'
MODIFY
src/before_plugin_rm.js
src/before_plugin_rm.js
@@ -3,11 +3,17 @@ module.exports = function(ctx) {
var fs = ctx.requireCordovaModule('fs'),
path = ctx.requireCordovaModule('path'),
Q = ctx.requireCordovaModule('q');
+ var projectRoot = ctx.opts.projectRoot,
+ configXmlPath = path.join(projectRoot, 'config.xml'),
+ NODE_MODULES_DIR;
- var xml2js = require('../node_modules/xml2js');
+ var versions = ctx.opts.cordova.version.split(/\./g);
+ NODE_MODULES_DIR = path.join(__dirname, '..', 'node_modules');
+ if (!fs.existsSync(NODE_MODULES_DIR)) {
+ NODE_MODULES_DIR = path.join(projectRoot, "node_modules");
+ }
- var projectRoot = ctx.opts.projectRoot,
- configXmlPath = path.join(projectRoot, "config.xml");
+ var xml2js = require(path.join(NODE_MODULES_DIR, 'xml2js'));
return Q.Promise(function(resolve, reject, notify) {
//---------------------------

Error: Cannot find module '../node_modules/xml2js' #2158