0

i exported some of my variable an a function in nodejs like below:

app.js:

var setting;
var savesetting = function(val, callback){ .....}
module.export =setting;
module.export = savesetting;

index.js:

var appjs = require('app');
appjs.savesettings(0,1);

appjs.savesettings(); cause an error which is:

Express
500 TypeError: Object #<Object> has no method 'savesettings'

any idea?

0

1 Answer 1

1
var app = {
   setting:{},
   savesetting : function(val, callback){ .....}
}
module.exports = app;

http://nodejs.org/api/modules.html

Sign up to request clarification or add additional context in comments.

2 Comments

actually, im looking for a way to access variables, function of a js file in another one.am i right to do it in this way??
i wrote the code for app.js, index.js should work with no modification.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.