获取错误 EBUSY:资源繁忙或锁定 [英] Getting Error EBUSY: resource busy or locked

查看:95
本文介绍了获取错误 EBUSY:资源繁忙或锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试运行 Nodejs 应用程序来测试 Raspberry 3 B + Gpio Onoff 模块,但是当我尝试运行该应用程序时出现此错误

Trying to run a Nodejs app to test Raspberry 3 B + Gpio Onoff Module but when i am trying to run the app getting this Error

fs.js:114
throw err;

Error: EBUSY: resource busy or locked, write
at Object.writeSync (fs.js:568:3)
at Object.writeFileSync (fs.js:1199:26)
at new Gpio (/home/pi/Desktop/pitesting/node_modules/onoff/onoff.js:96:10)
at Object.<anonymous> (/home/pi/Desktop/pitesting/blink.js:3:7)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)

这是我的应用代码

var onoff = require('onoff');
var Gpio = onoff.Gpio,
  led = new Gpio(4, 'out'),
  interval;
interval = setInterval(function () {
  var value = (led.readSync() + 1) % 2;
  led.write(value, function () {
    console.log("Changed LED state to: " + value);
  });
}, 2000);
process.on('SIGINT', function () {
  clearInterval(interval);
  led.writeSync(0);
  led.unexport();
  console.log('Bye, bye!');
  process.exit();
});

已经尝试通过更新和升级 apt 以及重新安装节点模块来修复.

Already Tried Fixes by updating and upgrading apt and reinstalling node modules.

请帮我解决这个问题.

推荐答案

GitHub 上有很多关于这个问题的答案.

There are many answers on GitHub regarding this issue.

  • 有人说npm cache clean 这个在终端上执行的命令解决了这个问题.

  • Some says npm cache clean this command executing on terminal solved the problem.

其他人建议删除您的应用所在文件夹的整个目录并重新安装软件包,然后尝试运行该程序.

Others recommend to delete the entire directory your app is the folder in and re-install the packages and then try running the program.

有些人还说这是反恶意软件引起的,建议在运行程序时禁用它.

Some also says that It is caused by the anti-malware software and recommend to disable it while running the program.

GitHub 问题链接:https://github.com/npm/npm/issues/13461

GitHub issue link: https://github.com/npm/npm/issues/13461

如果它不能解决问题,只需将 GPIO 引脚更改为编码中的 23,并且不要忘记也将 LED 从 4 物理替换为 23.

If it doesn't solve the issue, just change the GPIO pin to let's say 23 in coding and don't forget to physically replace LED from 4 to 23 too.

这篇关于获取错误 EBUSY:资源繁忙或锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆