I'm writing a web app in Node. If I've got some JS file db.js
with a function init
in it how could I call that function from the command line?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Keeping track of variable instances
Install run-func to your project
Run any exported function
Any following arguments will be passed as function parameters
init(param1, param2)
This can also run from "scripts" section in package.json
Important
init
must be exported in your db.js fileor ES6 export
Simple, in the javascript file testfile.js:
Running at the prompt: