缺少配置模块 属性
config module missing property
我有一个云配置模块:
var express = require('express');
var app = express();
var cloudinary = require('cloudinary');
var config = require('./config.json')[app.get('env')];
module.exports = function(){
cloudinary.config({
cloud_name: config.cloudinary_cloud_name,
api_key: config.cloudinary_api_key,
api_secret: config.cloudinary_api_secret
});
return cloudinary;
};
我用它:
var cloudinary = require('../config/cloudinary');
cloudinary.uploader.upload(file.path, function (result) {
我收到这个错误:
Cannot read property 'upload' of undefined
当您执行 require('../config/cloudinary')
时,它不会执行该功能。你可以这样使用它:
var cloudinary = require('../config/cloudinary')();
cloudinary.uploader.upload(file.path, function (result) {
我有一个云配置模块:
var express = require('express');
var app = express();
var cloudinary = require('cloudinary');
var config = require('./config.json')[app.get('env')];
module.exports = function(){
cloudinary.config({
cloud_name: config.cloudinary_cloud_name,
api_key: config.cloudinary_api_key,
api_secret: config.cloudinary_api_secret
});
return cloudinary;
};
我用它:
var cloudinary = require('../config/cloudinary');
cloudinary.uploader.upload(file.path, function (result) {
我收到这个错误:
Cannot read property 'upload' of undefined
当您执行 require('../config/cloudinary')
时,它不会执行该功能。你可以这样使用它:
var cloudinary = require('../config/cloudinary')();
cloudinary.uploader.upload(file.path, function (result) {