module.js:341
throw err;
^
Error: Cannot find module 'clarifai'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/Users/shiva/seefood-backend/app.js:4:16)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
當我做node app.js
時,我在終端上面收到上面的消息。我已經安裝了https://developer.clarifai.com/quick-start/與npm install clarifai
上提到的Clarifai npm軟件包,但它仍然給我這個錯誤。我是否需要全球安裝軟件包? 另外這是我app.js
:當我啓動節點服務器時未找到npm模塊
var express = require('express')
var app = express();
var bodyParser = require('body-parser')
var Clarifai = require('clarifai')
var secrets = require('./secrets')
var keys = secrets.clarifaiConfig()
app.use(bodyParser.json());
var ClarifaiInstance = new Clarifai.App(
keys.access_key,
keys.secret_key
)
var store
var foodModel = 'bd367be194cf45149e75f01d59f77ba7'
var fnol = function getPredictionAsJSON(imageURL) {
ClarifaiInstance.models.predict(foodModel, imageURL).then(
function(response) {
store = response.outputs[0].data
console.log(store + ' from inside the fn');
},
function(err) {
console.error(err);
}
);
return store
}
app.listen(8000, function() {
console.log('Recognize app listening on port 8000!')
app.post('/classify', function(req, res) {
var clarifaiData
var imageURL = req.body.imageURL
clarifaiData = fnol(imageURL)
// console.log('cldata : '+ clarifaiData)
var responseObject = {imageURL: imageURL, data: clarifaiData }
// console.log('rObj : '+responseObject)
res.send((responseObject));
});
app.get('/classify', function(req, res) {
res.json((store));
});
})
試過,沒有幫助:( – ShivaV