How to run an Express app with powershell

Question:

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:

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>

Answer:

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

Source:

How to run an Express app with powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply