Search code examples
npmtitaniumappceleratortitanium-alloy

Npm strange bug, Titanium Appc Alloy


this is what I'm doing var Promise = require("bluebird");, but when I'm lauching my app on android, I got this error, for actual no reason (imo)

[ERROR] TiExceptionHandler: (main) [99,287] ti:/module.js:297
[ERROR] TiExceptionHandler:     throw new Error('Requested module not found: ' + request); // TODO Set 'code' property to 'MODULE_NOT_FOUND' to match Node?
[ERROR] TiExceptionHandler:  ^
[ERROR] TiExceptionHandler: Error: Requested module not found: bluebird
[ERROR] TiExceptionHandler:     at Module.require (ti:/module.js:297:8)
[ERROR] TiExceptionHandler:     at Module.global.Module.require (<embedded>:19327:34)
[ERROR] TiExceptionHandler:     at require (ti:/module.js:550:15)
[ERROR] TiExceptionHandler:     at /utilities.js:3:15
[ERROR] TiExceptionHandler:     at Module._runScript (ti:/module.js:587:9)
[ERROR] TiExceptionHandler:     at Module.load (ti:/module.js:106:7)
[ERROR] TiExceptionHandler:     at Module.loadJavascriptText (ti:/module.js:436:9)
[ERROR] TiExceptionHandler:     at Module.loadAsFile (ti:/module.js:488:15)
[ERROR] TiExceptionHandler:     at Module.loadAsFileOrDirectory (ti:/module.js:410:20)
[ERROR] TiExceptionHandler:     at Module.require (ti:/module.js:290:17)
[ERROR] TiExceptionHandler:
[ERROR] TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Function.nativeInvoke(Native Method)
[ERROR] TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Function.callSync(V8Function.java:55)
[ERROR] TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Function.call(V8Function.java:41)
[ERROR] TiExceptionHandler:     ti.modules.titanium.TitaniumModule$Timer.run(TitaniumModule.java:167)
[ERROR] TiExceptionHandler:     android.os.Handler.handleCallback(Handler.java:938)
[ERROR] TiExceptionHandler:     android.os.Handler.dispatchMessage(Handler.java:99)
[ERROR] TiExceptionHandler:     android.os.Looper.loop(Looper.java:223)
[ERROR] TiExceptionHandler:     android.app.ActivityThread.main(ActivityThread.java:7656)
[ERROR] TiExceptionHandler:     java.lang.reflect.Method.invoke(Native Method)
[ERROR] TiExceptionHandler:     com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
[ERROR] V8Exception: Exception occurred at ti:/module.js:297: Uncaught Error: Requested module not found: bluebird

Don't worry I know how to use npm (I guess), I tried to clear the cache, delete node_modules, delete package.json, reinstall everything, "npm install" then "npm install bluebird", but still got this issue, I tried to clean my project too, restart vs code, hope you have any idea how to fix it :(


Solution

  • Place the bluebird.js file into app/lib if it is not there and use var Promise = require("/bluebird"); to require it. Works fine here (Titanium 10.0.0.GA, node 14, Android 11, Pixel 4)