Last active
April 20, 2020 16:07
-
-
Save scripting/3e5454f2b7a10029dfc301d7deabb576 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.helloWorld = function () { | |
| return ("hello world"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "requirefromstringtest", | |
| "description": "Test requirefromstring package.", | |
| "author": "Dave Winer <dave@scripting.com>", | |
| "version": "0.4.0", | |
| "scripts": { | |
| "start": "node test.js" | |
| }, | |
| "dependencies" : { | |
| "require-from-string": "*" | |
| }, | |
| "license": "MIT", | |
| "engines": { | |
| "node": "*" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require ("fs"); | |
| const requireFromString = require ("require-from-string"); | |
| fs.readFile ("mymodule.js", function (err, moduletext) { | |
| var val = requireFromString (moduletext.toString ()).helloWorld (); | |
| console.log (val); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment