I like javascript, so I was excited when I heard about Node.js, a V8-based Javascript runtime. I would prefer to do my shell scripting going forward in Javascript. My issue is this: how can I run my scripts without calling node ~/Scripts/myscript.js
? After I chmod +x
my script, it tries to run as a bash script instead of a Node.js javascript.
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- google-drive can't get push notifications
- How to reimport module with ES6 import
- Why is `node.js` dying when called from inside pyt
- Xcode debugger displays incorrect values for varia
相关文章
- 现在使用swift开发ios应用好还是swift?
- node连接远程oracle报错
- Visual Studio Code, MAC OS X, OmniSharp server is
- How can make folder with Firebase Cloud Functions
- xcode 4 garbage collection removed?
- IntelliJ IDEA can't open projects or add SDK o
- Automator: How do I use the Choose from List actio
- @angular-cli install fails with deprecated request
Whats making your current shell starting the bash is that your current shell (bash?) has no clue about what to do with a file.js. Thats why the gods of unix invented the shebang for:
So, in your case I would try to put
at the top of the script. You can see that beeing applied for example in the 'inode' (interactive node.js) shell, which might be another option to fire your scripts.
https://github.com/bancek/node-interactive-shell/blob/master/inode.js
You can always simply create a shell script that runs node for you.
Alternatively, if you want to create a script that can run in an environment that doesn't have node.js installed, you can use installer-maker.