這是我在 json 檔案中的代碼,每當我嘗試運行它時,我都會收到此錯誤:TypeError: Class constructor Wia can be called without 'new' at Object. (/home/pi/wia-pi-camera/run-camera.js:3:25)
'use strict';
var wia = require('wia')('your-device-secret-key');
var fs = require('fs');
var RaspiCam = require("raspicam");
// Setup the camera
var camera = new RaspiCam({
mode: 'photo',
output: __dirname '/photo.jpg',
encoding: 'jpg'
});
// Listen for the "start" event triggered when the start method has been successfully initiated
camera.on("start", function(){
console.log("Starting to take photo.");
});
// Listen for the "read" event triggered when each new photo/video is saved
camera.on("read", function(err, timestamp, filename){
console.log("New photo created.", timestamp, filename);
// Publish the photo to Wia
wia.events.publish({
name: 'photo',
file: fs.createReadStream(__dirname '/' filename)
});
});
// Take a photo
camera.start();
第二行是錯誤似乎發生的地方: var wia = require('wia')('my_device_secret_key');
有誰知道如何解決這一問題?
uj5u.com熱心網友回復:
像這樣嘗試:
const Wia = require('wia');
var wia = new Wia('your-device-secret-key');
require('wia')回傳一個類,您需要呼叫它new來創建一個實體。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/357341.html
標籤:javascript 节点.js json 终端 树莓派
