Can't start webdriver-manager after upgrading of jdk, node & webdriver - node.js

I've upgraded Node, Protractor, JDK & webdriver to the latest versions.
And now I can't start webdriver-manager anymore not by CMD and not by Node command line.
Any idea?
Error:
Your environment has been set up for using Node.js 0.12.2 (x64) and npm.
C:\Users\idan>cd c:\automation\tests\node_modules\protractor\bin
c:\automation\tests\node_modules\protractor\bin>webdriver-manager start
selenium.pid: 6484
'java' is not recognized as an internal or external command,
operable program or batch file.
Selenium Standalone has exited with code 1
c:\automation\tests\node_modules\protractor\bin>

You need to have jdk installed and JAVA_HOME environment variable set:
How to set java_home on Windows 7?
Also see:
'Java' is not recognized as an internal or external command

Yeah whoever made webdriver-manager, made too many assumptions... :S
Find webdriver-manager\built\lib\cmds\start.js On my machine it's
C:\Users\XYZ\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\built\lib\cmds\start.js
Find the line that starts with
var seleniumProcess = spawnCommand
replace that line and the preceding line with
logger.info(process.env.JAVA_HOME+'\\bin\\java.exe' + argsToString);
var seleniumProcess = spawnCommand(process.env.JAVA_HOME+'\\bin\\java.exe', args);
Set your JAVA_HOME and you're set.
If you don't know how to set your JAVA_HOME, do this:
Run Command Prompt (cmd.exe) with admin privileges and then run
dir c:\java.exe /s/a/b
After a while, you will get at least one line of text such as
C:\Dev\Java\JDK\jre\bin\java.exe
If you get no text lines you don't have java on C drive. :( Repeat for other letters or install a Java JRE.
Pick any of those lines of text. Your java_home is that line of text except bin\java.exe. To set it, in my case I would do:
setx /m JAVA_HOME C:\Dev\Java\JDK\jre\
setx will set JAVA_HOME permanently machine-wide. If you want to set JAVA_HOME permanently for the current user remove the /m parameter. If you want to set JAVA_HOME temporarily, only for that opened "Command Prompt" window do this:
set JAVA_HOME=C:\Dev\Java\JDK\jre\
Good luck.

I ran the command
webdriver-manager start
and got the above error messages.
Then followed David C instructions for this question and it finally worked. But before that, I had to install the JDK as well. Here are the complete steps.
I searched for install java jdk windows 10 64 bit and ended up on this Java JDK Installation.
Scrolled a bit and clicked on JDK Installation Instructions for Windows
As per the instructions there, again went hunting for Java SE Development Kit 10 Downloads and ended up on Java SE Development Kit 13 Downloads page. That seems to be the latest as of now
Downloaded the Windows x64 Installer. The file name looked like this jdk-13.0.2_windows-x64_bin.exe. 13 seems to be the latest.
On my machine, took a look at C:\Program Files\Java. This JAVA folder is not yet present.
Run the exe downloaded with admin privliages.
Ensure that java is installed by peeking at C:\Program Files\Java. I have got a folder inside that as C:\Program Files\Java\jdk-13.0.2.
Now followed David C's instructions. Opened up a command prompt and ran
dir c:\java.exe /s/a/b
Confirmed that my path is c:\Program Files\Java\jdk-13.0.2\bin\java.exe
Now I run, in the same admin command prompt,
setx /m JAVA_HOME "c:\Program Files\Java\jdk-13.0.2"
setx JAVA_HOME "c:\Program Files\Java\jdk-13.0.2"
Finally caught hold of start.js. Mine is located at C:\Users\XYX\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\built\lib\cmds
Commented the following lines
//logger.info('java' + argsToString);
//let seleniumProcess = utils_1.spawn('java', args, stdio);`
and replaced them with
logger.info(process.env.JAVA_HOME+'\\bin\\java.exe' + argsToString);
let seleniumProcess = utils_1.spawn(process.env.JAVA_HOME+'\\bin\\java.exe', args, stdio);
Now ran the command
webdriver-manager start
Finally got it. - Selenium Server is up and running on port 4444
Such a pain going through all of these steps.

Related

Running npm in cmd giving me errors, I just installed nodejs msi on windows

I installed nodejs in Windows system from official website and npm giving errors:
CALL "C:\Program Files\node js\\node.exe" "C:\Program Files\nodejs\\node_modules\npm\bin\npm-cli.js" prefix -g' is not
recognized as an internal or external command, operable program or batch file.
I have given all sorts of paths. Please help me.
http://prntscr.com/gso39z
Add the following paths to your PATH environment variable
%USERPROFILE%\AppData\Roaming\npm
C:\Program Files\nodejs\
(note that i have windows 10, where your programs are installed can differ as per your windows version)
To permanently set PATH environment variable, follow these steps:
This PC/ My Computer Properties
Advanced System Settings, (right side)
from popup, click environment variable
select PATH environment variable under system variable, (not user variable) then click edit
Click new, and copy and paste one of the path (given) there.
new again and paste second path
to check if its set or not, goto terminal, and type PATH
note: if you type PATH, its value will be displayed, but if you type %PATH% , each of its value will act as a command input to terminal (windows terminal -_-).
Start the process by being an administrator.
Open up your command prompt as an administrator.
And if you are using older version of node say 6.9, please upgrade to 6.10, it may solve your problem.

Not able to use npm in WIndows

Error message in cmd.exe
Hi
I'm not able to use npm on Windows 8.1 64bit. It shows the error message as in image link. I have installed nodejs v5.7.1
ERROR MESSAGE:
'CALL "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules
\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external com
mand,
operable program or batch file.
3.6.0
Tried changing PATH variables and installing a fresh copy in a different drive also
Please help.
Thanks
Download Cygwin
Launch Cygwin Terminal as Administrator, then run the following command
curl -L "https://npmjs.org/install.sh" | sh
This will do a fresh install of NPM. It could take a while to download but once the install completed if everything was successful, the last thing printed will be It Worked.
EDIT: Changed from npm-windows-upgrade to Cygwin
Go to your environment variables and on the system variables section remove the ComSpec variable
First delete this two folders
C:\Users\<your user name>\AppData\Roaming\npm
C:\Users\<your user name>\AppData\Roaming\npm cache
Then delete the Comspec system variable.
It works definitely on windows machine.
solution is very simple...open advance windows system settings
next....edit environment variable..in that...open system variable..in that...change comSpec value o C:\Windows\system32\cmd.exe...then press OK

'node' is not recognized as an internal or an external command, operable program or batch file while using phonegap/cordova

I am using phonegap/cordova.
Everthing is installed propelry i.e cordova, phonegap, ant,sdk,jdk.
But now it says "node is not recogzed as an internal or external command"
In Windows, you need to set node.js folder path into system variables or user variables.
1) open Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables
2) in "User variables" or "System variables" find variable PATH and add node.js folder path as value. Usually it is C:\Program Files\nodejs;. If variable doesn't exists, create it.
3) Restart your IDE or computer.
It is useful add also "npm" and "Git" paths as variable, separated by semicolon.
Great answers, but you could just open the command prompt and type in
SET PATH=C:\Program Files\Nodejs;%PATH%
Worked for me by running the command prompt as an administrator
Add a system variable named "node", with value of your node path.
It solves my problem, hope it helps.
If you install Node using the windows installer, there is nothing you have to do. It adds path to node and npm.
You can also use Windows setx command for changing system environment variables. No reboot is required. Just logout/login. Or just open a new cmd window, if you want to see the changing there.
setx PATH "%PATH%;C:\Program Files\nodejs"
As you're using Windows, installation should automatically edit the %PATH% variable. Therefore, I suspect you simply need to reboot your system after installing.
Be aware that the Path is case sensitive. I tried setx PATH and it didn't work. In my case it was setx Path. Make sure your CMD run as Administrator.
setx Path "%PATH%;C:\Program Files\nodejs"
Now just restart your command prompt (or restart the PC) and the node command should be available.
Also, try to run nvm on to turn on the node. Worked for me.
If you already have node installed, your path variable is set up and you suddenly start getting this error; try updating to the latest version.
This worked for me going from 6.9.2 to 6.10.
In my case, I'm using NVM and it installed Node v16.2.0, which for some reason has node.exe named as node64.exe. I changed it to node.exe and everything just worked.
In windows search bar type "enviroment variable" open it and set path
C:\Program Files\nodejs;
After adding path in system enviroment variable, If problem still occurs then follow steps
Close cmd and open new cmd, try "node" command.
For VS code close all windows and reopen then try "node" command.
If above steps didn't work then restart system.(this one worked for me)
I tried the solutions above but uninstall and reinstall of nodejs from installer the only one worked for me.
In my case I was using nvm-windows and JetBrains Rider. The required paths were specified in environment variables, but MSBuild wasn't picking them up. Apparently I haven't rebooted my PC after installing NVM. Rebooting the PC fixed the problem.
Please install node through nvm
following command will give you the path where node is installed .
nvm root
Current Root: C:\Users\u725561\AppData\Roaming\nvm
node would be present inside the subdirectory of nvm root .
add the directory C:\Users\u725561\AppData\Roaming\nvm\v12.22.2 to path environment variable.
I had the same problem. My solution was just restart :/
If you have this problem, you should just try restart first...
Try to add the version at the end in the PATH variable
C:\Program Files\nodejs\16.x.x
**Wnidows-11**
control panel---Advance system setting----Enviornment Variable---new----Variable Name(Path) Varibale value(C:\Program Files\nodejs or whichever your path)
Afterwards restart your cli and node -v then boom!!
enter image description here
Make sure that the node.exe exists in C:\Program Files\nodejs\, then add it to the path. ( See above answers to see how)
I am using chocolate package manger for installing nodejs by running choco install nodejs. Surprisingly in some versions the node.exe was not created in C:\Program Files\nodejs\ !
So make sure the node.exe is in C:\Program Files\nodejs\
I went through all the comments here, none of them worked. I found I had to uninstall and reinstall node.js and then it worked. Probably not the best solution but try this answer at the bottom of the list if all else fails...
For me I just click on empty session and it works for me

ERROR: executing command 'ant' - After installation and setting ANT_HOME

After wrestling with my environment variables to get the proper directory set, I can now get the version with:
C:\Projects\TestProj>ant -version
Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ant appears to be working:
C:\Projects\TestProj>ant
Buildfile: build.xml does not exist!
Build failed
I still get the error when I try:
C:\Projects\TestProj>cordova -d platform add android
cordova library for "android" already exists. No need to download. Continuing.
Checking if platform "android" passes minimum requirements...
Creating android project...
Running command: C:\Users\Administrator\.cordova\lib\android\cordova\3.4.0\bin\c
reate.bat --cli C:\Projects\TestProj\platforms\android com.company.testproj
TestProj
C:\Users\Administrator\.cordova\lib\android\cordova\3.4.0\bin\node_modules\q\q.j
s:126
throw e;
^
Error: ERROR : executing command 'ant', make sure you have ant installed and add
ed to your path.
From all of the posts that I have read, this is an issue with ANT_HOME, but it appears I have that part of it tackled. Edit I've installed ant 1.9.3 to program files, and bin resides in:
EDIT Changed to just ant, instead of apache-ant-1.9.3-bin\apache-ant-1.9.3
C:\Program Files\ant
Echo home:
C:\Projects\TestProj>echo %ANT_HOME%
C:\Program Files\ant
And of course I have %ANT_HOME%\bin in my path. Any help identifying the issue would be appreciated.
I think the path you use for ANT_HOME is wrong. C:\Users\Administrator\AppData\Roaming\npm\node_modules\ant\ant seems to be the path to the ant npm module but not the ant command.
Ant command more probably is somewhere in program files. In a cmd, run where ant to know where in your path ant is found and use this path for ANT_HOME. (in the folder you should see ant, ant.cmd and ant.bat)
After further investigation, I think your problem is caused half by cordova not correctly checking node errors and half because of registry setting in your computer (a cmd autorun parameter).
You can check answers in those posts for more info:
nodejs child_process exec 'java -version'
Windows CMD.exe "The system cannot find the path specified."
Check if you have a registry key HKCU\Software\Microsoft\Command Processor\AutoRun
after setting the variables, restart your machine. Closing command prompt etc will not help.
Even I was stuck for quite a long time and next day when I started my system, it was working fine :P

Node.JS - How to Run Node Command from any path?

I have installed the latest node.js from here . I see the %Path% variables have been set for Node.js. But, When i run node from C:\ , i get a "Node is not an recognized comman". But node command is working fine from "C:\Program Files (x86)\nodejs" path. Can i not run Node commands from C:\ or Say from an other path if i set the Env variables right? Please help. I am running a Win7 X64.
Thank You,
Faraaz
I had the exact same problem, but in my PATH variable I had: C:\Program Files\nodejs\.
After changing it to C:\Program Files\nodejs I could access it from anywhere.
What happens if you run node --version? I have never tried node.js from windows but if that doesn't work there is something wrong with your paths.
What do you get when you run echo %PATH%?
You should check if the path C:\Program Files (x86)\nodejs is present in your %PATH. If not, add it via the system properties (persistent change). In any case, restart your command prompt, it'll reload the %PATH variable. If you're lucky, it should work now :)
Most likely it happens because there is no Node path in your PATH environment variable.
I see two ways to solve this
Just add Node path into the end of PATH.
Reinstall Node as administrator
run 7-zip (or some file manager) with administrator privileges >>
browse to node-installer.msi >> open it, install node >> enjoy
My Sublime was working with Nodejs fine. I could press Alt-R and see the output from Node in Sublime. Then at some point I upgraded Sublime. I now have version 2.02 build 2221
And at some later point I tried Alt-R and got this infamous message
'node' is not recognized as an internal or external command
But it had worked, so what changed?
The steps I took to fix it were to install git bash and then
$ git clone https://github.com/tanepiper/SublimeText-Nodejs.git
$ cd SublimeText-Nodejs/
$ git checkout 095ba03344
Back in Sublime I clicked Preferences > Browse Packages. This opened up Windows Explorer with the folder:
C:\Users\me\AppData\Roaming\Sublime Text 2\Packages
I replaced the contents of the Nodejs folder with the git version. Re-started Sublime and then Alt-R sprang back into life.
Other things that turned out to be irrelevant were changing the file Nodejs.sublime-settings and tampering with system environment variables. The only thing that worked was 095ba03344 as described here
https://github.com/tanepiper/SublimeText-Nodejs/pull/39

Resources