How do I split npm scripts into multiple lines?

My package configuration includes long scripts. For instance, consider the new code sample:

{
  "name": "demoProject",
  "scripts": {
    "check": "node_check --output custom .",
    "compile:api": "node_compile source.js -out out/api --ignore temp,cache"
  }
}

How can I structure these commands over several lines without resorting to separate shell scripts?

hey, try using the backslash to escape newlines in your script cmd. it lets u break the line into multiple parts in shell. note that on windows it might act a bit odd tho, so test it in your env. hope this helps!

One potential solution is to create an inline Node script that constructs and executes the desired command. This approach allows the command to be defined in a more structured manner over multiple lines, thereby enhancing readability. The script can be kept minimal and solely responsible for chaining together the various parts of your command. While this does add an extra file to your project, it prevents the package device from becoming unwieldy and mitigates compatibility issues across different shells. In practice, this method has proven effective while maintaining clarity in complex setups.