How to pass flags to nodejs application through npm run-script? : <p>I've a NodeJS file that I run via an "npm" command. I've been trying to list all arguments (including flags). If I run it by directly calling the node exe, it works fine but if I use the <code>npm</code> command, I cannot access the flags.</p>

<p>Code:</p>

<pre><code>console.dir(process.argv);
</code></pre>

<p>When I run the file like this,</p>

<pre><code>node file.js arg1 arg2 -f --flag2
</code></pre>

<p>I can get all of the arguments.</p>

<pre><code>[ '/usr/local/bin/node',
  '/.../file.js',
  'arg1',
  'arg2',
  '-f',
  '--flag2' ]
</code></pre>

<p>But if I add an npm runner to the package.json file and try to run with it, I can only get the arguments but not the flags.</p>

<pre><code>npm run test arg1 arg2 -f --flag2
</code></pre>

<p>The result:</p>

<pre><code>[ '/usr/local/bin/node',
  '/.../file.js',
  'arg1',
  'arg2' ]
</code></pre>

<p>package.json file:</p>

<pre><code>{
  "name": "name",
  "version": "1.0.0",
  "description": "",
  "main": "test.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" &amp;&amp; exit 1",
    "test" : "node test.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}
</code></pre>

<p>Basically, node won't pass flags to the running script. Is there a solution for this? My real project has a long path with a lot of arguments so I want to use a shortcut to test it.</p>
