javascript - 使用 Eric Smekens node-bluetooth-obd 的 ELM327 蓝牙 OBD-II 适配器

标签 javascript node.js bluetooth

当我尝试运行 Eric Smekens node-bluetooth-obd test.js 时,我收到以下错误 ReferenceError: require is not Defined in browser

添加 require.js 时出现以下错误“错误:模块名称“../lib/obd.js”尚未加载上下文:_。使用 require([]) http://requirejs.org/docs/errors.html#notloaded

我已经在 Firefox 和 IE Edge 上对此进行了测试,请就这些错误提出任何建议。

我只是运行它们来理解代码,尽管它不会在这里执行。

最佳答案

该模块应该在 Node.js 环境中使用,而不是在浏览器环境中使用。

安装 Node.js,然后在命令行中使用 npm init 创建一个 package.json 文件,安装模块 npm install --save bluetooth- obd,然后在脚本中使用它,如 require('bluetooth-obd')。要运行该脚本,请输入 node myscript.js

关于javascript - 使用 Eric Smekens node-bluetooth-obd 的 ELM327 蓝牙 OBD-II 适配器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42646643/

相关文章:

javascript - Rails `remote: true` 未发出 AJAX 请求

mysql - 在mysql中连接两个表时遇到SequelizeEagerLoadingError

ios - BLE 后台模式 : didUpdateValueForCharacteristic not called

java - J2SE 中的手机监控器

android - 如何检测具有相同标识符的多个信标?

javascript - 附加内容后没有 css 样式(使用 ajax)

javascript - naturalHeight 和 naturalWidth 属性是新增的还是已弃用?

javascript - 如何在表达式中引用模块变量?

javascript - 读取 ReadableStream 并指定大小参数 : Why does state. highWaterMark 总是作为大小传递给 ._read()?

node.js - 如果用户经过身份验证,就阻止他们再次登录 Passportjs?