【问题标题】:Npm strange bug, Titanium Appc Alloynpm 奇怪的 bug,钛 Appc 合金
【发布时间】:2021-08-30 14:16:46
【问题描述】:

这就是我正在做的var Promise = require("bluebird");,但是当我在 android 上启动我的应用程序时,我收到了这个错误,实际上没有任何原因 (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

别担心,我知道如何使用 npm(我猜),我尝试清除缓存,删除 node_modules,删除 package.json,重新安装所有内容,“npm install”然后“npm install bluebird”,但仍然得到这个问题,我也尝试清理我的项目,重新启动vs代码,希望你知道如何解决它:(

【问题讨论】:

    标签: npm titanium appcelerator titanium-alloy


    【解决方案1】:

    如果 bluebird.js 文件不存在,请将其放入 app/lib 并使用 var Promise = require("/bluebird"); 来要求它。在这里工作正常(Titanium 10.0.0.GA,node 14,Android 11,Pixel 4)

    【讨论】: