Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在react native中使用SNMPJS_Javascript_React Native - Fatal编程技术网

Javascript 在react native中使用SNMPJS

Javascript 在react native中使用SNMPJS,javascript,react-native,Javascript,React Native,我想使用SNMP连接到打印机,我遇到了这个库-。然而,当我尝试在reactnative平台中使用相同的时,我得到了错误 import snmp from 'net-snmp'; const session = snmp.createSession('10.20.27.221', 'public', 161); const oids = ['1.3.6.1.2.1.1.5.0', '1.3.6.1.2.1.1.6.0']; session.get(oids, (error, varbinds)

我想使用SNMP连接到打印机,我遇到了这个库-。然而,当我尝试在reactnative平台中使用相同的时,我得到了错误

import snmp from 'net-snmp';
const session = snmp.createSession('10.20.27.221', 'public', 161);
const oids = ['1.3.6.1.2.1.1.5.0', '1.3.6.1.2.1.1.6.0'];

session.get(oids, (error, varbinds) => {
if (error) {
    console.error(error);
} else {
        console.log(varbinds[0].value);
  }
});
session.trap(snmp.TrapType.LinkDown, (error) => {
if (error) {
    console.error(error);
}
});
当我尝试执行上面的代码时,我在android模拟器上得到了以下错误

The development server returned response error code: 500
URL: http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false

Body:
{"from":"/Users/Documents/projects/auth/node_modules/net-snmp/index.js","to":"dgram","message":"Unable to resolve module dgram from /Users/Documents/projects/auth/node_modules/net-snmp/index.js: Module does not exist in the module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n 1. Clear watchman watches: watchman watch-del-all.\n 2. Delete the node_modules folder: rm -rf node_modules && npm install.\n 3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start -- --reset-cache.","name":"UnableToResolveError","type":"UnableToResolveError","errors":[{}]}
processBundleResult
BundleDownloader.java:225
access$100
BundleDownloader.java:40
onResponse
BundleDownloader.java:192
execute
RealCall.java:135
run
NamedRunnable.java:32
runWorker
ThreadPoolExecutor.java:1162
run
ThreadPoolExecutor.java:636
run
Thread.java:764

是否有人使用了使用react native的SNMP协议?最好的方法是什么?

安装软件包后是否运行了
react native link
?是的,我也这样做了。安装软件包后是否运行了
react native link
?是的,我也这样做了。