Use java script file client side and server side at a time in node js
node js
include
call
javascript
In node js there is a module called as vm, this module is used to call javacsript functions both server side and client side at a time. Install vm module by using "npm install vm" .
If want to use vm module also install fs module. fs module is used to read the file. Install fs module by using "npm install fs" .
Below code for include external javascript file,
var fs = require('fs'); var vm = require('vm'); vm.runInThisContext(fs.readFileSync(__dirname + "/public/controllers/globalCalls.js")); console.log(ShowAttachmentName('ekg'));
You might also like:
A Very Big Sum | Javascript | hackerrank07-05-2020 A Very Big Sum Javascript hackerrank |
Time Sorting Ascending or Descending Order in Javascript19-07-2017 Javascript ascending order descending order |
How to make an http request in node js14-03-2017 http module node js |
Filter for change Date format (MM-dd-yyyy) in Angular Js05-03-2017 mm-dd-yyyy date formats angular js |
Filter for replace text in Angular Js05-03-2017 filter replace angular js |