how to pass parameters to npm run lite command

375 views
Skip to first unread message

Reza Razavipour

unread,
Mar 31, 2017, 2:26:34 PM3/31/17
to Angular and AngularJS discussion
I have number of different versions of my Angular app. I want those to be driven by custom run time parameters such --framework xyz or some such things. 
I read about configuration files for lite-server but it looks like it supports a certain set of arguments.

What is the recommended way to provide for an example of command to be:
npm run lite --framework xyz?

Sander Elias

unread,
Apr 1, 2017, 6:30:05 AM4/1/17
to Angular and AngularJS discussion
Hi Reza,

You can use a double dash (--) to add your own parameters that then end up as a parameter directly to the thing you put in the script.
sample
in package.json
....
{ scripts; {
   
"ngs": "ng serve
   }
}
...

Yo can then do something like:
npm run ng -- --aot false --prod

to get the parameters through.

Hope this helps
Regards
Sander


Reza Razavipour

unread,
Apr 1, 2017, 3:05:23 PM4/1/17
to ang...@googlegroups.com
the stand alone -- is not a typo ? -- --aot false? 

Regards,
Reza

--
You received this message because you are subscribed to a topic in the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/lLmEa6LZ5PM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+unsubscribe@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Sander Elias

unread,
Apr 1, 2017, 10:49:34 PM4/1/17
to Angular and AngularJS discussion
Nope, it's mandatory. It's a npm switch that means, whatever follows is not for me but for the command I'm going to execute.

Reza Razavipour

unread,
Apr 3, 2017, 11:40:25 AM4/3/17
to ang...@googlegroups.com
It is usually process.env.myparam to retrieve the argument, not the same in Angular. 
How is it done in Angular? I read browser.param. Is that the case? If so, where is browser defined?



Regards,
Reza

On Sat, Apr 1, 2017 at 7:49 PM, Sander Elias <sande...@gmail.com> wrote:
Nope, it's mandatory. It's a npm switch that means, whatever follows is not for me but for the command I'm going to execute.
Reply all
Reply to author
Forward
0 new messages