Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run an Express app with powershell

I want to run an ExpressJS app by using Powershell. It works with cmd when I use SET DEBUG=myApp:* & npm start, but it won't work in the powershell. The error message is as follows:

At line:1 char:24
+ SET DEBUG=helloworld:* & npm start
+                        ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
    + CategoryInfo: ParserError: (:) [],ParentContainsErrorRecordException
    + FullyQualifiedErrorId : AmpersandNotAllowed  

I've tried to eliminate the ampersand or wrap it around quotations marks but to no avail; I keep getting further error messages. I've googled this but haven't found the answer.

I want to know what is the command to be used in powershell to run my ExpressJS app.

By using some other commands suggested by other users, I get the following error:

PS C:\Users\User\myNode\helloworld> [Environment]::SetEnvironmentVariable("DEBUG","helloworld:"‌​); & npm start At line:1 char:61 + [Environment]::SetEnvironmentVariable("DEBUG","helloworld:"‌​); & np ... + ~ Missing ')' in method call. At line:1 char:61 + ... Environment]::SetEnvironmentVariable("DEBUG","helloworld:"‌​); & npm ... + ~~ Unexpected token '‌​' in expression or statement. At line:1 char:63 + ... nvironment]::SetEnvironmentVariable("DEBUG","helloworld:"‌​); & npm ... + ~ Unexpected token ')' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall

PS C:\Users\User\myNode\helloworld> [Environment]::SetEnvironmentVariable("DEBUG","helloworld:* & npm start") PS C:\Users\User\myNode\helloworld>

like image 660
Pablo Avatar asked Feb 07 '17 17:02

Pablo


1 Answers

PS C:\Users\hp\Desktop\myapp> set DEBUG='myapp:*'; npm start

like image 157
ravina verma Avatar answered Oct 03 '22 10:10

ravina verma