node.js - 约翰尼五的 Npm 错误
问题描述
当我 npm install johnny 5 时,它不会下载目录。当我尝试使用 johnny 5 piezo 示例运行我的 index.js 文件时,它只是不想运行。给我一个关于串口的错误。我尝试安装串口,没有用。还尝试重新安装 node 和 npm,但这也没有用。这是我的 index.js:
var five = require("johnny-five"),
board = new five.Board();
board.on("ready", function() {
// Creates a piezo object and defines the pin to be used for the signal
var piezo = new five.Piezo(3);
// Injects the piezo into the repl
board.repl.inject({
piezo: piezo
});
// Plays a song
piezo.play({
// song is composed by an array of pairs of notes and beats
// The first argument is the note (null means "no note")
// The second argument is the length of time (beat) of the note (or non-note)
song: [
["C4", 1 / 4],
["D4", 1 / 4],
["F4", 1 / 4],
["D4", 1 / 4],
["A4", 1 / 4],
[null, 1 / 4],
["A4", 1],
["G4", 1],
[null, 1 / 2],
["C4", 1 / 4],
["D4", 1 / 4],
["F4", 1 / 4],
["D4", 1 / 4],
["G4", 1 / 4],
[null, 1 / 4],
["G4", 1],
["F4", 1],
[null, 1 / 2]
],
tempo: 100
});
// Plays the same song with a string representation
piezo.play({
// song is composed by a string of notes
// a default beat is set, and the default octave is used
// any invalid note is read as "no note"
song: "C D F D A - A A A A G G G G - - C D F D G - G G G G F F F F - -",
beats: 1 / 4,
tempo: 100
});
});
这是它抛出的错误:
PS C:\Users\Krisztian\Desktop\proba> node index.js
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module '@serialport/bindings'
Require stack:
- C:\Users\Krisztian\node_modules\serialport\lib\index.js
- C:\Users\Krisztian\node_modules\johnny-five\lib\board.js
- C:\Users\Krisztian\node_modules\johnny-five\lib\accelerometer.js
- C:\Users\Krisztian\node_modules\johnny-five\lib\johnny-five.js
- C:\Users\Krisztian\Desktop\proba\index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\Users\Krisztian\node_modules\serialport\lib\index.js:2:17)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Krisztian\\node_modules\\serialport\\lib\\index.js',
'C:\\Users\\Krisztian\\node_modules\\johnny-five\\lib\\board.js',
'C:\\Users\\Krisztian\\node_modules\\johnny-five\\lib\\accelerometer.js',
'C:\\Users\\Krisztian\\node_modules\\johnny-five\\lib\\johnny-five.js',
'C:\\Users\\Krisztian\\Desktop\\proba\\index.js'
]
}
此外,每当我尝试安装 npm 包时,我都会收到很多错误和警告。
解决方案
推荐阅读
- python - 使用 GCMLE 训练时 GCP 上的 gapic-google-cloud-logging-v2 错误
- mysql - MySQL 不正确的排序
- angular - 角材料 | 模块的元数据版本不匹配
- angular - Angular Tour of Heroes - 包含测试项目但无法正常工作
- google-cloud-platform - google-speech-api 和覆盖电话号码识别
- ajax - 如何在 Laravel5.6 中使用 AJAX 调用资源控制器的编辑方法
- html - 响应式导航按钮
- android - 清除 TextureView 上的最后一帧预览
- python - 如何备份或恢复当前 python 文件的数据?
- r - 如何使用 MatchIt 函数来识别给定变量(倾向得分)的影响?