Creating my own module?


I was trying to do my own module/js import which contains:

exports.ReturnAll = function () {
    return collection;

and imported it like this:

var vocabulary = require("~/js/vocabulary.js");

and used it like this:


but then it throws an error:

TypeError: vocabulary.ReturnSpecified is not a function File: "/data/data/org.nativescript.ExpandVocabularyKorea/files/app/views/alphabet/alphabet.js, line: 50, column: 15

and I’ve been searching on google with no luck, how can I fix this problem, please help. Thank you… :slight_smile:


In your sample you added ReturnAll and you are calling ReturnSpecified.
I think you just pasted wrong function here.


you don’t need / should not specify the .js in your require statement


I made a mistake about this report… ReturnAll and ReturnSpecified are all included in the js… I apologise for the misunderstanding…

I will try your suggestion… Thank you… :slight_smile:


This is a screenshot of the code and the problem… I can’t explain it in written form properly… so here it is… :smiley:


Try this: require("…/…/js/vocabulary")

I’ve never seen ~ used in code before, as I understand that takes you to your home folder on the computer rather than the root of your project.