Set alias for Nodejs with harmony argument in Powershell - node.js

Im need to using node --harmony each time when working with node.recently im working with koajs and in the home page of koajs sayed can use this command
alias node='node --harmony'
but when i calling this command on powershell i get this error :
alias : This command cannot find a matching alias because an alias with the name 'node=node --harmony' does not exist.
At line:1 char:1
+ alias node='node --harmony'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (node=node --harmony:String) [Get-Alias], ItemNotFoundException
+ FullyQualifiedErrorId : ItemNotFoundException,Microsoft.PowerShell.Commands.GetAliasCommand
so how can change alias of node to node with harmony argument?

Related

Node.js: Access Denied

Just installed node.js on Windows 10 via msi installer.
Any command results to access denied error.
PS D:\sasha\Angular\ExampleShop> node -v
Сбой выполнения программы node.exe: Отказано в доступестрока:1 знак:1
+ node -v
+ ~~~~~~~.
строка:1 знак:1
+ node -v
+ ~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
Eventually, resolved the issue by myself. I changed Owner of the folder in which I installed node.js to my domain account.

Error while running java script in terminal using Node.js

This is the code i have written in my tut63.js file
code
console.log('Hello World');
when i type node tut63.js in terminal it was suppose to show " Hello World ".
But instead it is showing this error in terminal.
code
PS C:\Users\m\Desktop> node.tut63.js
The term 'node.tut63.js' is not recognized as the name of a cmdlet, function, script file, or oper
able program. Check the spelling of the name, or if a path was included, verify that the path is c
orrect and try again.
At line:1 char:14
node.tut63.js <<<<
CategoryInfo : ObjectNotFound: (node.tut63.js:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException

I am not able to move or navigate to a file in vscode terminal powershell

I have made a folder name notes and my terminal is present in notes folder currently and I am trying to move further in a file called web.js ,so I used command cd web/ which isn't seem to work and is always throwing error I also tried *cd ./web/ , cd .\web* ,nothing is working don't know why ? can anyone help me out? I need to open npm in my web.js file but not able to do so...
Kindly Help:)!
This is the error :
Devlopment\Notes\web\' because it does not exist.
At line:1 char:1
+ cd web/
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:
\Web Devlopment\Notes\web\:String) [Set-Locat
ion], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Micros
oft.PowerShell.Commands.SetLocationCommand```
If you need to rund web.js you can use
node web.js
cd works only with folders. You can cd into notes but web.js is a file that you can run via scripts.

AWS Userdata not working on Windows server 2019

Current setup:
Manually launched Windows server 2019 instance with nodes app in AWS.
Below commands are working fine with this instance
Pm2 delete myapp
Pm2 start
Issue :
We have created AMI of the above instance and launched it with a cloudformation template.
In the userdata of cloudformation template, we have made some changes in the config file of nodejs and restarting the nodes app with the above commands.
Output:
config file modified successfully with cloduformation userdata
Error:
The above commands (Pm2 delete myapp and Pm2 start) failed in the execution of userdata. below is the userdata log.
The errors from user scripts: pm2 : The term 'pm2' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Windows\TEMP\UserScript.ps1:15 char:1
+ pm2 delete RenderWorker
+ ~~~
+ CategoryInfo : ObjectNotFound: (pm2:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
pm2 : The term 'pm2' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Windows\TEMP\UserScript.ps1:16 char:1
+ pm2 start
+ ~~~
+ CategoryInfo : ObjectNotFound: (pm2:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Other findings:
Pm2 command is available with newly launched ec2 instance.
C:\Users\Administrator>pm2
usage: pm2 [options] <command>
pm2 -h, --help all available commands and options
pm2 examples display pm2 usage examples
pm2 <command> -h help on a specific command
Access pm2 files in ~/.pm2
Userdata in cloudofrmation:
UserData:
Fn::Base64: !Sub |
<powershell>
$config = '{
"MyENV": "${MyENV}",
"UR1L": "${URL1}",
"URL2": "${URL2}",
"BUCKET": "${MyBucket}",
"PATH": "${Mypath}"
}'
echo $config
$config | Set-Content C:\Projects\myapp\settings\config.json
cd 'C:\Projects\myapp'
pm2 delete RenderWorker
pm2 start
</powershell>
<runAsLocalSystem>true</runAsLocalSystem>
<persist>true</persist>
I doubt that you can run pm2 directly like that because the path to pm2 does not exist under SYSTEM path.
You are likely required to include the full path of it as follows to run the command.
For example, your pm2 resides under C:\etc\ then you need to include as follows:
C:\etc\.pm2 delete RenderWorker
C:\etc\.pm2 start
or if you are familiar with the path, you can make it as an environment variable.

msbuild DeployOnBuild=true argument not working

I am trying to automatically publish all the projects of my .NET solution using the DeplyOnBuild=true argument (according to this answer )
I typed this command in the PowerShell:
msbuild mysolultion.sln /p:Configuration=Debug;DeployOnBuild=true;
But I get the following error message :
The term 'DeployOnBuild=true' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:59
+ msbuild mysolution.sln /p:Configuration=Debug;DeployOnBuild=true <<<< ;
+ CategoryInfo : ObjectNotFound: (DeployOnBuild=true:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I am not sure what I am doing wrong.
PowerShell is interpreting everything after your first semicolon as a separate command.
You need to use quotes:
MSBuild example.sln /p:"Configuration=Debug;DeployOnBuild=true;"
Or use separate /p parameters:
MSBuild example.sln /p:Configuration=Debug /p:DeployOnBuild=true

Resources