"strict mode" doesn't get enabled for nodejs script when runing through forever
See original GitHub issueI have a script that uses strict mode, it’s an executable script with a “#!/usr/bin/node --harmony” shebang and runs fine when I directly call it from the terminal. I use this line at the start of the script to enable strict mode:
#!/usr/bin/node --harmony
"use strict";
However, if I run it through forever (forever start script_name) I obtain the following error in the logs that causes the script to abort over and over:
let report = {
^^^
SyntaxError: Unexpected strict mode reserved word
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
error: Forever detected script exited with code: 8
Is there some way for me to indicate to forever that I want to run the nodejs script in strict mode? Or how can I specity commandline arguments for the node binary when running forever?
EDIT: I also tried doing this:
if(process.argv[2] == "start") {
require("forever").start(__filename, {
'uid': 'script_name',
'minUptime': 500,
'spinSleepTime': 0.5 * 60 * 1000,
'command': 'node',
'args': [ '--use_strict', '--harmony' ]
});
}
This didn’t work either, I get the same result.
EDIT2: Funnily enough, I found it works when I use ‘perl’ as the command interpreter…
if(process.argv[2] == "start") {
require("forever").start(__filename, {
'uid': 'script_name',
'minUptime': 500,
'spinSleepTime': 0.5 * 60 * 1000,
'command': 'perl'
});
}
Looks like perl executes the file correctly after reading the shebang.
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
Yes. Either that or just do what most folks I know do and put
"use strict"
at the top of every one of your source code files.I figured out the following incantation to make things work; This is working in production for the Heroku dashboard w/iojs: