Skip to content

Cannot import node-api module #366

@owl352

Description

@owl352

Good day! I started preparing my module for release and encountered a problem during testing in React Native: I couldn't import the napi module either through require with babel.config.js or through requireNodeAddon.

Error:

[DEBUG] [NodeApiHost] [pshenmic-dpp--pshenmic_dpp] Loading addon by '@rpath/pshenmic-dpp--pshenmic_dpp.framework/pshenmic-dpp--pshenmic_dpp'
[DEBUG] [NodeApiHost] NapiHost: Failed to load library '@rpath/pshenmic-dpp--pshenmic_dpp.framework/pshenmic-dpp--pshenmic_dpp': dlopen(@rpath/pshenmic-dpp--pshenmic_dpp.framework/pshenmic-dpp--pshenmic_dpp, 0x0006): tried: '/Users/bebra/Library/Developer/Xcode/DerivedData/expopshenmicdpptest-fkfdlwyzamtrzididrrosigrycfm/Build/Products/Debug-iphonesimulator/pshenmic-dpp--pshenmic_dpp.framework/pshenmic-dpp--pshenmic_dpp' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_23C54/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 26.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/pshenmic-dpp--pshenmic_dpp.framework/pshenmic-dpp--pshenmic_dpp' (no such file), '/usr/lib/swift/pshenmic-dpp--pshenmic_dpp.framework/pshenmic-dpp--pshenmic_dpp' (no such file, not in dyld cache), '/Users/bebra/Library/Developer/CoreSimulator/Devices/52938A97-D32A-46EB-A0BE-5D731586A09C/data/Containers/Bundle/Application/E542311F-D1B4-4181-B20E-9333E4A5E096/expopshenmicdpptest.app/Frameworks/pshenmic-dpp--pshenmic_dpp.framework/pshenmic-dpp--pshenmic_dpp' (no such file), '/Users/bebra/Library/Developer/CoreSimulator/Devices/52938A97-D32A-46EB-A0BE-5D731586A09C/data/Containers/Bundle/Application/E542311F-D1B4-4181-B20E-9333E4A5E096/expopshenmicdpptest.app/Frameworks/pshenmic-dpp--pshenmic_dpp.framework/pshenmic-dpp--pshenmic_dpp' (no such file), '/Users/bebra/Library/Developer/CoreSimulator/Devices/52938A97-D32A-46EB-A0BE-5D731586A09C/data/Containers/Bundle/Application/E542311F-D1B4-4181-B20E-9333E4A5E096/expopshenmicdpptest.app/pshenmic-dpp--pshenmic_dpp.framework/pshenmic-dpp--pshenmic_dpp' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_23C54/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 26.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/pshenmic-dpp--pshenmic_dpp.framework/pshenmic-dpp--pshenmic_dpp' (no such file), '/usr/lib/swift/pshenmic-dpp--pshenmic_dpp.framework/pshenmic-dpp--pshenmic_dpp' (no such file, not in dyld cache), '/Users/bebra/Library/Developer/CoreSimulator/Devices/52938A97-D32A-46EB-A0BE-5D731586A09C/data/Containers/Bundle/Application/E542311F-D1B4-4181-B20E-9333E4A5E096/expopshenmicdpptest.app/Frameworks/pshenmic-dpp--pshenmic_dpp.framework/pshenmic-dpp--pshenmic_dpp' (no such file), '/Users/bebra/Library/Developer/CoreSimulator/Devices/52938A97-D32A-46EB-A0BE-5D731586A09C/data/Containers/Bundle/Application/E542311F-D1B4-4181-B20E-9333E4A5E096/expopshenmicdpptest.app/Frameworks/pshenmic-dpp--pshenmic_dpp.framework/pshenmic-dpp--pshenmic_dpp' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_23C54/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 26.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/pshenmic-dpp--pshenmic_dpp.framework/pshenmic-dpp--pshenmic_dpp' (no such file)
[DEBUG] [NodeApiHost] [pshenmic-dpp--pshenmic_dpp] Failed to load library

Steps for reproduce

  1. create react native app
  2. add to dependencies:
"dash-platform-sdk": "https://github.com/pshenmic/dash-platform-sdk#a6687586eff35faa0a35409be7a97294640cf95f",
"react-native-node-api": "1.0.1"
  1. paste App.tsx
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, View } from 'react-native';
import {IdentifierWASM, IdentityPublicKeyWASM, Purpose, SecurityLevel, KeyType} from "pshenmic-dpp";

export default function App() {
  const keyId = 0
  const purpose = Purpose.DECRYPTION
  const securityLevel = SecurityLevel.HIGH
  const keyType = KeyType.ECDSA_SECP256K1
  const binaryData = '036a394312e40e81d928fde2bde7880070e4fa9c1d1d9b168da707ea468afa2b48'

  const pubKey = new IdentityPublicKeyWASM(
    keyId,
    purpose,
    securityLevel,
    keyType,
    false,
    binaryData)

  const id = new IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')

  return (
    <View style={styles.container}>
      <Text>id base58: {id.base58()}</Text>
      <Text>id hex: {pubKey.keyType}</Text>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});
  1. run npx expo prebuild
  2. run npm run ios

This example use requireNodeAddon

I can't say that there might not be a mistake on my part somewhere here. I would appreciate any help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions