Try to avoid confusing literal linefeeds and literal backslash followed by literal n.
If you want the string you pass to have linefeeds, you should ignore JavaScript string literal syntax and just pass the linefeeds as linefeeds:
$ cat myNodeScript.js console.log("Node was passed this: " + process.argv[2]) $ cat myBashScript testString=' hello there' printf 'Bash passes this: %s\n' "$testString" node myNodeScript.js "$testString" $ bash myBashScript Bash passes this: hello there Node was passed this: hello there
Arguments should contain data (linefeed) while script files should contain code (quoted linefeed or expanded \n as appropriate in the language). When you make sure not to confuse code and data, you can trivially handle both backslash-en and linefeeds in the same string with no surprises:
testString=' "\nhello\nthere" is JavaScript syntax for: hello there'
There are ways to express this on a single line in bash using \n for linefeeds and \\n for backslash-en, you just need to make sure that it remains as code, and doesn't accidentally make it into the variable as data.