You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using SublimeREPL with node. I tried to load a module from a local file. The require command seems to run successfully but I get "not a function" when trying to run a function from within the module.
The same works fine when running from node command line.
Here is the contents of my primary js file:
console.log("Loading norm.js")
var norm=require("./norm.js")
console.log("Contents of norm module:")
console.log(norm)
// Now try to run a method from norm.js listed in exports
console.log("Output:")
let x=norm.normalizeAPI({ contact: {id:1, custom_field: {cf_country:'Canada'}}}, 'crm', 'contact')
console.log(x)
The module defines some functions and uses module.exports to export 3 of them.
When I run primary file from command line I get expected output:
But when I try to run same from within SublimeREPL, I get following output:
Loading norm.js
Contents of norm module:
{ }
Output:
Uncaught TypeError: norm.normalizeAPI is not a function
I use process.chdir to change to directory where files are located. Both the primary file and the module are in same directory.
require() must be finding the file because if I change the path to invalid filename I get error. It seems to me the problem is either no objects are being loaded or the exports are not set.
Inside the module, I have tried to export using module.exports= and exports=.
Is it possible to load a local file module from within SublimeREPL and if so, how?
The text was updated successfully, but these errors were encountered:
I'm using SublimeREPL with node. I tried to load a module from a local file. The require command seems to run successfully but I get "not a function" when trying to run a function from within the module.
The same works fine when running from node command line.
Here is the contents of my primary js file:
The module defines some functions and uses module.exports to export 3 of them.
When I run primary file from command line I get expected output:
But when I try to run same from within SublimeREPL, I get following output:
I use process.chdir to change to directory where files are located. Both the primary file and the module are in same directory.
require() must be finding the file because if I change the path to invalid filename I get error. It seems to me the problem is either no objects are being loaded or the exports are not set.
Inside the module, I have tried to export using module.exports= and exports=.
Is it possible to load a local file module from within SublimeREPL and if so, how?
The text was updated successfully, but these errors were encountered: