Windows is not recognizing serverless as internal or external command - serverless

I wanted to install serverless in my windows 7 machine.My npm version is 6.1.0.
I used the command
npm install -g serverless
C:\Users\ADMIN\AppData\Roaming\npm\serverless -> C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless\bin\serverless
C:\Users\ADMIN\AppData\Roaming\npm\slss -> C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless\bin\serverless
C:\Users\ADMIN\AppData\Roaming\npm\sls -> C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless\bin\serverless
> spawn-sync#1.0.15 postinstall C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless\node_modules\spawn-sync
> node postinstall
> serverless#1.30.1 postinstall C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless
> node ./scripts/postinstall.js
+ serverless#1.30.1
added 351 packages from 269 contributors in 154.064s
But when I type serverless in command prompt, it tells me
'serverless' is not recognized as an internal or external command,
operable program or batch file.

I had the same issue and I believe you are missing the npm path from your environment variables.
Go to Windows search and type:
"Edit the system environment variables"
(at least this is how you can find the Environment Variables in Windows 10).
Go to Advanced tab and click on Environment Variables.
Select Path from the User Variables and click Edit.
Click New and provide the following:
C:\Users[USER_NAME]\AppData\Roaming\npm\
or whatever is the path that you have installed npm - just change the [USER_NAME] with your username account.
Else you could navigate to the path above and execute "serverless" from inside that path.
Hope that helps :)

Try make use of npx
Example:
npx sls deploy

I had the same issue. In my Windows 10 system, I wanted to install serverless under Git Bash.
I was able to install serverless with the normal account just fine, but then the serverless command was not found (even after closing Git Bash and launching it again). After doing the same steps using Administrator privileges, everything worked fine even using the normal user account. Perhaps this will help someone.

^^Adding both environment paths, to npm and serverless/bin, worked for me. Same issue. Windows 10, trying to start a Serverless project after it seemingly installed correctly.
Going to it from /npm also worked, but the adding both environment paths was the permanent solution by #Suday Ghosh

Go to System Window (Control Panel\System and Security\System);
Click "Advanced System Settings"
Click "Environment Variables"
Select "Path" variables and click "Edit" Button
Under "Edit environment variable" window, Click "New" Button
Provide the following paths separately:
C:\Users[USER_NAME]\AppData\Roaming\npm\
AND
C:\Users[USER_NAME]\AppData\Roaming\npm\node_modules\serverless\bin
Happy !!!!!!

Related

Jenkins cannot find g++

I am learning all of these new technologies. I have a home server for private development with latest version of centos 7.6 (minimal installation). I am trying to keep the server as light as possible.
I have installed jenkins (v2.164.2) and it is up and running correctly. I have created a new Freestyle project to compile a g++ project hosted on another own gogs server. I have defined gogs url and credentials and then added the following in the execute shell command:
which g++; make clean; make;
When I press the "Build Now" button, it fails with the following message:
which: no g++ in (/sbin:/usr/sbin:/bin:/usr/bin)
Cloning the repository, etc seems to be working fine.
I have NOT installed the default g++ version but instead I have installed the one that comes with devtools-7 (g++ v7.3.1). I have created a new file under /etc/profile.d/devtools.sh with the following text:
!#/bin/bash
source scl_source enable devtoolset-7
If I login into a bash shell in the server and then run which g++, I get the expected output.
Finally, the question: why jenkins is not picking this up? As far as I know, adding that file under /etc/profile.d ensures that everyone will be able to access g++.
Thanks very much in advance for any help.
I have managed to fix it at the end. I leave the question just in case someone else runs into the same problem. I only had to add the following line as first line in the "execute shell" command field:
#!/bin/bash -l
make clean; make;
That #!/bin/bash -l did the trick. (Please mind the -l).
Found it here: What shell does Jenkins use?

How to update your surge.sh project?

I deployed a surge.sh project and it was published successfully, however, I want to make some updates to the project, the updates have been applied locally and can be seen working but it tried to publish it to the same domain again yet it doesn't appear updated. I also tried to tear down the project and re-upload it still it shows the old project, I cleared the cache too but it still didn't update. Any idea why?
To update a project you just need to publish it again to the same domain.
You can do this quickly by creating a file called CNAME in the project root directory to set the default domain name, like this:
echo site-name.surge.sh >CNAME
Then each time to update:
surge .
Alternatively, without a CNAME file, specify the domain in the surge command like this:
surge --domain site-name.surge.sh .
See https://surge.sh/help/remembering-a-domain .
This will not solve the need to tear down and republish the site described in the original post, but if you're not having that problem, it will make it quick to update your surge.sh project, as per the title question, without the need to edit the domain the usual prompt.
Open Git Bash.
Switch to the project directory.
Type surge and click Enter.
Click Enter in line "project".
Enter URL of your project in line "domain" and click Enter.
That's it!
Use the following deploy script to update your deployed Surge Project
"deploy": "surge --project ./path_to_build_folder --domain custom-domain.surge.sh"
Just go to your project folder, use cd to select your project directory, then type npm run build , then change directory to build directory cd build and then use surge
Edit:
Example \
You need go to your project directory, in my case it's jamming
$ cd ../
King#DESKTOP-5ERNS17 MINGW64 ~/Documents/Projects/jamming (main)
$ pwd
/c/Users/King/Documents/Projects/jamming
King#DESKTOP-5ERNS17 MINGW64 ~/Documents/Projects/jamming (main)
Then you do npm run build, I guess you need to update the build.
King#DESKTOP-5ERNS17 MINGW64 ~/Documents/Projects/jamming (main)
$ npm run build
Once the build is compiled, go in to the build directory by using cd build and then do surge
King#DESKTOP-5ERNS17 MINGW64 ~/Documents/Projects/jamming (main)
$ cd build
King#DESKTOP-5ERNS17 MINGW64 ~/Documents/Projects/jamming/build
$ surge
That's how it worked with me. If I don't do npm run build before the surge just won't update it... I don't know if this is the right way...
To update your Surge project, simply run surge in the project directory and input the same domain you're already using in the domain: prompt.
Some users are describing a problem where they have to do a hard refresh to see their updates. This is to be expected, and happens with any static file host, since static files are cached by your browser to make page loads faster.
So to see the latest version of your Surge site, press Ctrl+Shift+J or F12 to open the developer tools, and right-click on the reload button in the browser's unibar, and click on Empty Cache and Hard Reload.
Open Cmd.
Switch to the project directory.
Type surge . and click Enter.
and change the random domain with your web that's want to update and hit enter.
That's it <3
Go to the directory project and use git or cmd and this structure:
type surge and hit enter
hit enter in project line
replace the random domain with your web url
hit enter

iPad run with black screen in Jenkins

i configured out jenkins in way that it was launched under my account but when i build a project for my unit tests with KIF framework, Jenkins launches iPad simulator with black screen and nothing happens (jenkins also doesn't provide any useful information).
Can anyone advice to solution of this issue?
Please note that everything works just fine from command line.
Finally, i've found the solution need to use iPad Retina or iPad Retina (64-bit):
-destination OS=7.0,name=iPad Retina
So, the last supposed suggestion doesn't work either - need another solution.
Just ran into this myself. Following up on user2738882's self-answer, I have a fix for the pitfalls his solution has:
He's correct that it was occurring due to Jenkins being run as a launch daemon process. Daemon's are launched at start without login, but they aren't intended to have access to the UI. This is what causes the issue.
Unfortunately Jenkins defaults to installing as a launch daemon if you install via the Archive (.war).
The solution I went with is to move it over to a launch agent. To do so follow these steps:
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
sudo cp /Library/LaunchDaemons/org.jenkins-ci.plist /Users/<Path to Jenkins User>/Library/LaunchAgents/org.jenkins-ci.plist
Right click - > Get Info on the org.jenkins-ci.plist file
Change the read write permissions to all users (bottom)
Modify the plist file to change GroupName key value from "daemon" to "agent"
Right click -> Get Info again
Reset the file access to as it was before
sudo launchctl load /Users/<Path to Jenkins User>/Library/LaunchAgents/org.jenkins-ci.plist
The drawback of this approach is launch agents don't start until the user they're associated with logs in. In order to accommodate this I've configured my Jenkins user to login when the server starts up. To do this:
Open System Preferences
Open Groups & Users
Login Options
Set your Jenkins user as the Automatic Login:
This is obviously a security concern, but these machines should only ever be accessible on your local network and in a secure location anyway. Regardless I set the machine to show a screensaver as quickly as possible with a login.
The work-around that I see is that you can create AppleScript, which will run a simulator using terminal. Example:
do shell script "script"
where, script is your terminal command.
After script is created, add build step 'Execute shell script' to jenkins and write script which will run your AppleScript.
Example:
open /Applications/MyScript.app
The issue was in Jenkins and it was solved in the following way:
Stop the jenkins daemon via command:
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
Start Jenkins as process via command:
sudo nohup java -jar /Applications/Jenkins/jenkins.war --httpPort=8080 --ajp13Port=8010
And it works perfectly!
But there is a pitfall, after launching Jenkins under your user, all jobs disappear and you need to create it once again.

Install a Windows service using a Windows command prompt?

I want to install a Windows service using a Windows command prompt (not the Visual Studio command prompt).
How do I do this?
Navigate to the installutil.exe in your .net folder (for .net 4 it's C:\Windows\Microsoft.NET\Framework\v4.0.30319 for example) and use it to install your service, like this:
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" "c:\myservice.exe"
Regarding a comment, for 64bit apps, use below:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil.exe
Nothing wrong with SC Create command.
Just you need to know the correct args :
SC CREATE "MySVC" binpath= "D:\Me\Services\MySVC\MySVC.exe"
If the directory's name has a space like c:\program files\abc 123, then you must use double quotes around the path.
installutil.exe "c:\program files\abc 123\myservice.exe"
It makes things much easier if you set up a bat file like following,
e.g. To install a service, create a "myserviceinstaller.bat" and "Run as Administrator"
#echo off
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
installutil.exe "C:\Services\myservice.exe"
if ERRORLEVEL 1 goto error
exit
:error
echo There was a problem
pause
to uninstall service,
Just add a -u to the installutil command.
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe -u "C:\Services\myservice.exe"
Perform the following:
Start up the command prompt (CMD) with administrator rights.
Type c:\windows\microsoft.net\framework\v4.0.30319\installutil.exe [your windows service path to exe]
Press return and that's that!
It's important to open with administrator rights otherwise you may find errors that come up that don't make sense. If you get any, check you've opened it with admin rights first!
To open with admin rights, right click 'Command Prompt' and select 'Run as administrator'.
Source:
http://coderamblings.wordpress.com/2012/07/24/how-to-install-a-windows-service-using-the-command-prompt/
Install Service:-
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe"
"C:\Services\myservice.exe"
UnInstall Sevice:-
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe" -u "C:\Services\myservice.Service.exe"
Create a *.bat file beside of your windows service exe file for installing with the following context:
CLS
ECHO Installing My Windows Service
START %windir%\Microsoft.NET\Framework\v4.0.30319\installutil.exe "%~d0%~p0\YourWindowsServiceExeName.exe"
Create a *.bat file beside of your windows service exe file for uninstalling with the following context:
CLS
ECHO Uninstalling My Windows Service
START %windir%\Microsoft.NET\Framework\v4.0.30319\installutil.exe -u "%~d0%~p0\YourWindowsServiceExeName.exe"
Run each of bat file as Admin to install or uninstall your windows service.
I must add one more point in this thread. To install/uninstall 64-bit version of assemblies one should use 64-bit version of tool. To install a service, the command should be:
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe"
"C:\YourFolder\YourService.exe"
and to uninstall the command should be:
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe" -u
"C:\YourFolder\YourService.exe"
Run Windows Command Prompt as Administrator
paste this code: cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\ to go to folder
edit and run this too: installutil C:\ProjectFolder\bin\Debug\MyProject.exe
Note: To uninstall: installutil /u C:\ProjectFolder\bin\Debug\MyProject.exe
open Developer command prompt as Admin and navigate to
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
Now use path where is your .exe there
InstallUtil "D:\backup\WindowsService\WindowsService1\WindowsService1\obj\Debug\TestService.exe"
Open Visual studio and select new project by selecting Windows Service template in Windows Desktop tab. Than copy following code into your service_name.cs file.
using System.Diagnostics;
using System.ServiceProcess;
namespace TimerService
{
public partial class Timer_Service : ServiceBase
{
public Timer_Service()
{
InitializeComponent();
}
static void Main()
{
if (System.Diagnostics.Debugger.IsAttached)
{
Timer_Service service = new Timer_Service();
service.OnStart(null);
}
else
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new Timer_Service()
};
ServiceBase.Run(ServicesToRun);
}
}
protected override void OnStart(string[] args)
{
EventLog.WriteEvent("Timer_Service", new EventInstance(0, 0, EventLogEntryType.Information), new string[] { "Service start successfully." });
}
protected override void OnStop()
{
EventLog.WriteEvent("Timer_Service", new EventInstance(0, 0, EventLogEntryType.Information), new string[] { "Service stop successfully." });
}
}
}
Right-Click on service_name.cs file and open designer of service. than right-click and select Add Installer. than right-click on serviceProcessInstaller1 and change its property value of Account from User to Local System.
Remove static void main method from Program.cs file.
Than save and Build your project.
NOTE: goto bin\Ddebug folder of your project folder. Than open Properties of your service_name.exe file. Than goto Compatibility tab. Than click on Change Settings For All Users.
Select option Run this program as an administrator.
Now, You have to open CommandPromt as Administrator.
After open, set directory to where your InstallUtil.exe file is placed.
for ex: C:\Windows\Microsoft.NET\Framework64\v4.0.30319.
now write the following command:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe -i C:\TimerService\TimerService\bin\Debug\TimerService.exe
Note: -i is for install he service and -u for Unsinstall.
after -i set the write the path where you want to install your service.
now write the command in CommandPromt as follows:
C:\TimerService\TimerService\bin\Debug>net start service_name
Note: use stop for stop the Service.
Now, open ViewEventLog.exe. Select Windows Logs>Application. There you can check your Service's log by start and stop the service.
the following code , install and uninstall the Service,
Open the command prompt and run the program as an administrator and fire the below command and press enter.
Syntax
To Install
C:\windows\microsoft.net\framework\v4.0.30319>InstallUtil.exe + Your copied path + \your service name + .exe
eg :Our Path
InstallUtil.exe C:\MyFirstService\bin\Debug\MyFirstService.exe
To uninstall
C:\windows\microsoft.net\framework\v4.0.30319>InstallUtil.exe -u + Your copied path + \your service name + .exe
eg : Our path InstallUtil.exe -u C:\MyFirstService\bin\Debug\MyFirstService.exe
for more help you can see the following link: sample program
If you are using Powershell and you want to install .NET service you can use Install-Service module. It is a wrapper for InstalUtil tool.
It exposes 3 commands
Install-Service - invokesĀ InstallUtil.exe pathToExecutable command
Install-ServiceIfNotInstalled - first it checks if service is
installed if not perform the method Install-Service
Uninstall-Service- it uninstalls service. ServiceName of path to executable can be used.
Code to this module can be viewed here
start up the command prompt (CMD) with administrator rights.
Type c:\windows\microsoft.net\framework\v4.0.30319\installutil.exe [your windows service path to exe]
Press return
1.From the Start menu, select the Visual Studio directory, then select Developer Command Prompt for VS .
2.The Developer Command Prompt for Visual Studio appears.
3.Access the directory where your project's compiled executable file is located.
4.Run InstallUtil.exe from the command prompt with your project's executable as a parameter
when your assembly version and your Visual studio project Biuld setting on dot net 2 or 4 install with same version.
install service with installutil that same version
if build in dot net 4
Type c:\windows\microsoft.net\framework\v4.0.30319\installutil.exe
if build in dot net 2
Type c:\windows\microsoft.net\framework\v2.0.11319\installutil.exe
Follow these steps when deploying the Windows Service, don't lose time:
Run command prompt by the Admin right
Insure about release mode when compilling in your IDE
Give a type to your project installer on design view
Select authentication type in accordance the case
Insure about software dependencies: If you are using a certificate install it correctly
Go your console write this:
C:\Windows\Microsoft.NET\Framework\yourRecentVersion\installutil.exe c:\yourservice.exe
there is a hidden -i argument before the exe path -i c:\ you can use -u for uninstallling
Look your .exe path to seem log file. You can use event viewer to observing in the feature
you can do using command prompt and write:
C:\windows\microsoft.net\framework\v4.0.30319\InstallUtil.exe -i ".EXE file of window service"
You can use InstallUtil to install any windows service.
1: C:\Windows\Microsoft.NET\Framework64\v4.0.30319 in command prompt running as Adminstrator.
2: Copy the Exe path and type InstallUtil.exe "your exe path"
and hit enter.
If you want visual elaboration. Goto below link.
It helped me alot.
https://youtu.be/yrdyYxzI7SE
You should open command prompt, go to
C:\windows\microsoft.net\framework\v4.0.30319\InstallUtil.exe -i ".EXE file of window service"
Open command prompt as administrator, go to your Folder where your .exe resides.
To Install Exe as service
D:\YourFolderName\YourExeName /i
To uninstall use /u.

How to run Ruby and GIT commands in one place on Windows

I have Ruby and GIT installed on my windows box. To run GIT commands I am utilizing the GIT Bash. To run Ruby commands I am using the command line.
I have not been successful running GIT commands from the CMD line nor can I seem to run Ruby commands from inside the GIT Bash. I would love to be able to run commands for both GIT and Ruby from the GIT Bash (ideal) or at the least from the CMD line.
What is the best way to go about this?
I run git commands from the CMD session all the time.
Make sure your PATH environment variable includes the 'cmd' directory from a msysgit distro:
Path=C:\Path\To\Git\1.7.1\cmd
If not, add it in your session:
set PATH=%PATH%;C:\Path\To\Git\1.7.1\cmd
and you are done. Git and Ruby commands in your CMD shell.
The reverse (Ruby commands) is possible in a Git bash, by adding to the PATH a value like /c/path/to/Ruby/186-27/bin
To elaborate on VonC's answer of making Ruby available in Git-Bash.
All you have to do is add the path to your Ruby bin folder in your windows environment variables. It doesn't have to be in the format /c/path/to/ruby, it can be C:\Ruby193\bin.
Step by step for Windows 7:
Start
Search programs and files (default textbox after hitting the Start icon), Search for 'environment'
Select 'edit the system environment variables'
Click 'Environment Variables' (bottom right of the form)
Add to the 'System Variables' 'PATH' the following ';C:\Ruby193\bin' (without the single quotes)
Restart your shell
Make sure to close your git-bash shell and restart it to pick up the new environment variable.
Go to My Computer -> Properties -> Advanced system settings ->
Environment Variables
Add a New System variable. Variable name = RUBY_BIN. Variable
value = C:\Ruby193\bin (path may vary).
Add a New System variable. Variable name = MSYSGIT_BIN. Variable
value = C:\msysgit\bin (path may vary).
Append ;%RUBY_BIN%;%MSYSGIT_BIN% to Path variable, under System variables.
Restart shell.
This will allow you to run ruby, git or sh (Git Bash) commands from Command Prompt, as well as Ruby from Git Bash.
My personal setup uses msysgit and tortoisegit. I've found that using TortoiseGit's Pageant manager for the keys lets me use everything from any command line, including powershell. The only annoyance is I have to have pageant running with the keys added, which seem to clear on every reboot. Fortunately I don't reboot often.
The combined answer for VonC and Rots helped me to achieve the desired results.
However, since I was not familiar with editing environment variables, I must have accidentally overwritten the path for my nodejs files.
As a result my solution included adding the ruby path and the nodejs path to my user variables instead of the system.
I'm using a Windows 7 machine.
while installing ruby installer, select the option "Add ruby executables to your path" . Then all git/ruby commands will run from git bash.

Resources