Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24791] Android: SDK 6_X_X issue with local JS require

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 6.0.0, Release 6.1.0, Release 6.0.4
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterIbrahim MESLEM
AssigneeUnknown
Created2017-06-07T09:14:07.000+0000
Updated2018-02-28T19:55:03.000+0000

Description

Hello, I am facing an issue since the SDK 6_X_X on android , where i have the issue bellow *[ERROR] : TiExceptionHandler: (main) [125,125] ----- Titanium Javascript Runtime Error ----- [ERROR] : TiExceptionHandler: (main) [0,125] - In ti:/module.js:303,2 [ERROR] : TiExceptionHandler: (main) [0,125] - Message: Uncaught Error: Requested module not found: crypto-js/hmac [ERROR] : TiExceptionHandler: (main) [0,125] - Source: throw new Error("Requested module not found: " + request); // TODO Set 'code' property to 'MODULE_NOT_FOUND' to match Node? [ERROR] : V8Exception: Exception occurred at ti:/module.js:303: Uncaught Error: Requested module not found: crypto-js/hmac * The same lib working fine on 5_5_X, could you please help me with this. Best regards.

Comments

  1. Hans Knöchel 2017-06-07

    Hey there, is the same happening for 6.1.0.GA?
  2. Ibrahim MESLEM 2017-06-07

    Hey , yes :(
  3. Hans Knöchel 2017-06-07

    Thank you! Can you attach the file that caused the issue and an example code triggering the error as well?
  4. Ibrahim MESLEM 2017-06-07

    yes ofcourse, This is the lib that im using https://drive.google.com/file/d/0B7S72-3VTSUfenZIb0xUOTBnUHM/view?usp=sharing var CryptoJS = require(crypto-js/aes);
  5. Christopher Williams 2017-06-07

    [~bahinapster] We'd need to know the folder structure of your app (specifically the file calling require and the crypto-js/aes file). "Legacy"-style requires with no prefix should still be handled and assumed to be relative to your Resources folder (so require('crypto-js/aes') should look for Resources/crypto-js/aes.js) - but are now discouraged in favor of either explicitly absolute or relative require paths (i.e. require('./crypto-js/aes') to look relative to the current file, require('/crypto-js/aes') to look at Resources/crypto-js/aes.js)
  6. Ibrahim MESLEM 2017-06-07

    Both lib and my file are under app/lib as bellow app/lib/crypto-js app/lib/myfile.js
  7. Ewan Harris 2017-06-07

    Minimal test case

    Add the below to your titanium project (assuming classic here)

    Build for Android

       var CryptoJS = require('index');
       console.log(CryptoJS)
       
       ;(function (root, factory) {
       	module.exports = exports = factory();
       }(this, function (CryptoJS) {
       	(function () {
       		var x = 'foo';
       	}());
       }));
       
    I am able to fix this by either removing the nested iife in index.js or returning that iife. I tried this on iOS and it appears to load fine, -I have not tried Windows- Update: Window works as expected Removed foo.js file as index.js is enough to repro

JSON Source