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:
1 2 3 4 5 6 7 |
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>
Answer:
PS C:\Users\hp\Desktop\myapp> set DEBUG=’myapp:*’; npm start