profile
viewpoint

Ask questionsunresolved module nanoid on MacOS 10.15/iOS 13/Node 10.20/ipfs 0.43.3/LC 0.7.8

The LiquidCore 0.7.8 works fine before ipfs 0.43.3 installed with yarn add ipfs. There are 3 modules which is unresolvable - nanoid, utf-8-validate and bufferutil. After yarn add nanoid utf-8-validate bufferutil, the nanoid remains unresolvable. I did yarn add nanoid again and here is the installation message:

$ yarn add nanoid yarn add v1.22.0 warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json. [1/4] 🔍 Resolving packages... [2/4] 🚚 Fetching packages... warning Pattern ["nanoid@^3.1.5"] is trying to unpack in the same destination "/Users/zhouyiyun/Library/Caches/Yarn/v6/npm-nanoid-3.1.5-56da1bb76b619391fc61625e8b4e4bff309b9942-integrity/node_modules/nanoid" as pattern ["nanoid@^3.0.2","nanoid@^3.1.3","nanoid@^3.0.2"]. This could result in non-deterministic behavior, skipping. [3/4] 🔗 Linking dependencies... warning "ipfs > prometheus-gc-stats@0.6.2" has incorrect peer dependency "prom-client@>= 10 < 12". [4/4] 🔨 Building fresh packages... success Saved 1 new dependency. info Direct dependencies └─ nanoid@3.1.5 info All dependencies └─ nanoid@3.1.5 $ liquidcore postinstall Pod config complete ✨ Done in 12.60s. zhouyiyundeAir:nodejs_lc zhouyiyun$ pod install Analyzing dependencies Downloading dependencies Generating Pods project Integrating client project Pod installation complete! There are 3 dependencies from the Podfile and 3 total pods installed.

Here is the code in example.js which causes the error:

 const Ipfs =. require("ipfs")

The code launching the service is:

LCMicroServiceEventListener {

@IBOutlet weak var label1: UILabel!

func onEvent(_ service: LCMicroService, event: String, payload: Any?) {
    if event == "ready" {
        service.emit("ping")
    } else if event == "pong" {
        let p = (payload as! Dictionary<String, AnyObject>)
        let message = p["message"] as! String
        DispatchQueue.main.async {
            self.label1.text = message
        }
    }
}

func onStart(_ service: LCMicroService) {
    service.addEventListener("ready", listener: self)
    service.addEventListener("pong", listener: self)
}

@IBAction func click(_ sender: UIButton) { //<<<<<=== click the button to launch service
    txt = "In button click"
    showText()
    
    let url = LCMicroService.bundle("example")
    let service = LCMicroService(url: url)
    service?.start()
  
}

var txt = "text field"

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
    label1.text = "Initial Label"
  }

func showText() {
    label1.text = txt
}

}

After click the button, the debug console shows the message:

2020-05-07 13:09:56.107740-0700 nodejs_lc[69749:24565022] MicroService User-Agent : LiquidCore/0.7.8 (iOS; API=13.3) 2020-05-07 13:10:05.262004-0700 nodejs_lc[69749:24565022] ursaNative has no registered native binding. 2020-05-07 13:10:05.389680-0700 nodejs_lc[69749:24565022] secp256k1 has no registered native binding. 2020-05-07 13:10:05.897140-0700 nodejs_lc[69749:24565022] stderr: Require cycle: node_modules/glob/glob.js -> node_modules/glob/sync.js -> node_modules/glob/glob.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. 2020-05-07 13:10:06.087506-0700 nodejs_lc[69749:24565022] stderr: Require cycle: node_modules/ipfs/src/core/components/index.js -> node_modules/ipfs/src/core/components/init.js -> node_modules/ipfs/src/core/components/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. 2020-05-07 13:10:06.157026-0700 nodejs_lc[69749:24565022] There is an unhandled exception! 2020-05-07 13:10:06.157361-0700 nodejs_lc[69749:24565022] Error: Error: Cannot resolve module 2020-05-07 13:10:06.158389-0700 nodejs_lc[69749:24565022] Stack: :180416 <Source line not available>

example.bundle.js:180416:18 loadModuleImplementation@example.bundle.js:290:14 example.bundle.js:180216:18 loadModuleImplementation@example.bundle.js:290:14 example.bundle.js:180191:26 loadModuleImplementation@example.bundle.js:290:14 example.bundle.js:180127:18 loadModuleImplementation@example.bundle.js:290:14 example.bundle.js:180102:44 loadModuleImplementation@example.bundle.js:290:14 2020-05-07 13:10:06.162419-0700 nodejs_lc[69749:24565022] There is an unhandled exception! 2020-05-07 13:10:06.163651-0700 nodejs_lc[69749:24565022] Error: null 2020-05-07 13:10:06.173615-0700 nodejs_lc[69749:24565022] Stack: undefined :496 <Source line not available>

[native code] emit@events.js:189:18 internal/bootstrap/node.js:496:31 anon@[native code]:2:16

BTW the ipfs 0.43.3 works fine in my other nodejs project. Many thanks.

LiquidPlayer/LiquidCore

Answer questions ericwlange

I believe the issue is that IPFS is trying to use ursaNative and secp256k1 native modules, which are not built for LiquidCore. I've gotten this to work in the past. You need to hack whichever module is trying to load those native bindings to skip them and use the JS-only implementations.

useful!

Related questions

No questions were found.
Github User Rank List