NPM Package.json scripts section

Why do my npm command-line arguments disappear?

Georgi Parlakov
2 min readOct 7, 2019

Or how to pass arguments down.

Have you ever had to pass in arguments “down” to the inner npm script and dash-dash-ed them? And then maybe you had a double or triple nest i.e. one npm command calling another that in turn calls another and so on.

Screenshot of console running npm command with nested npm command
I have to write more and know precisely how many levels deep the rabbit hole goes...

While this works there are a few drawbacks:
- I need to know exactly how many commands are nested and which one I want to pass command-line arguments
- I need to type more

So here’s my approach to this:

Screenshot of package.json in the scripts part showing scripts with dash-dash at the end

Leave the nesting commands with an ending -- so command-line call would not need to add multiple dash-dash but only one:

Screenshot of command line running npm script

--

--

Georgi Parlakov
Georgi Parlakov

Written by Georgi Parlakov

Angular and DotNet dev. RxJs explorer. Testing proponent. A dad. Educative.io course author. https://gparlakov.github.io/

No responses yet