running towerjs on windows 8 gives a TypeError - windows

I installed tower#0.4.2-22 on my windows 8 machine. After this I tried to verify the installation. I started mongod server, the tower server and called http://localhost:3000 in my browser. I get the error messages (in browser window and server log):
TypeError: Object Windows 8 has no method 'match'
at Object.Tower.MiddlewareAgent [as handle] (C:\Users\Philipp\Documents\Scripts\tower\Tests\test01\node_modules\tower\lib\tower-middleware\server\agent.js:13:21)
at next (C:\Users\Philipp\Documents\Scripts\tower\Tests\test01\node_modules\tower\node_modules\connect\lib\proto.js:199:15)
at Object.handle (C:\Users\Philipp\Documents\Scripts\tower\Tests\test01\app\config\server\bootstrap.coffee:23:14)
at next (C:\Users\Philipp\Documents\Scripts\tower\Tests\test01\node_modules\tower\node_modules\connect\lib\proto.js:199:15)
at Object.methodOverride [as handle] (C:\Users\Philipp\Documents\Scripts\tower\Tests\test01\node_modules\tower\node_modules\connect\lib\middleware\methodOverride.js:37:5)
at next (C:\Users\Philipp\Documents\Scripts\tower\Tests\test01\node_modules\tower\node_modules\connect\lib\proto.js:199:15)
at multipart (C:\Users\Philipp\Documents\Scripts\tower\Tests\test01\node_modules\tower\node_modules\connect\lib\middleware\multipart.js:64:37)
at module.exports (C:\Users\Philipp\Documents\Scripts\tower\Tests\test01\node_modules\tower\node_modules\connect\lib\middleware\bodyParser.js:57:9)
at urlencoded (C:\Users\Philipp\Documents\Scripts\tower\Tests\test01\node_modules\tower\node_modules\connect\lib\middleware\urlencoded.js:51:37)
at module.exports (C:\Users\Philipp\Documents\Scripts\tower\Tests\test01\node_modules\tower\node_modules\connect\lib\middleware\bodyParser.js:55:7)
I tried to figure out what's happened and find out that in module
\node_modules\tower\lib\tower-middleware\server\agent.js
the method calls
mac: !!agent.os.match(/mac/i),
windows: !!agent.os.match(/win/i),
linux: !!agent.os.match(/linux/i)
failed because agent.os is of type object and not string.
I replaced the lines with
mac: !!agent.os.toString().match(/mac/i),
windows: !!agent.os.toString().match(/win/i),
linux: !!agent.os.toString().match(/linux/i)
and tower comes up and is running.
Is this a bug in the code or was something wrong with my installation?
First I installed tower with npm install power -g
Then I created a app with tower new test01
The next steps were:
- cd test01
- npm install
- forever server.js (failed forever wasn't installed)
- npm install forever -g
- forever server.js (failed mongod wasn't started)
- (started mongodb)
- forever server.js (is running now)
- cake watch (in another prompt - failed, because grunt missing)
- npm install grunt -g
- cake watch (now it's running)
- (go to browser and enter http://localhost:3000)
- (see error description above)

Seems to be a recent bug, probably something that has changed in recent versions of node.js or one of Tower's other depencies, I noticed tower has suddenly gotten a few bug reports for this over the past couple of days, and looks like someone submitted a patch last night
so watch for either that pull request to get accepted or pull it into your own fork of tower.js and try again.

Related

Can't properly install hardhat using Powershell! Persistent Error HH12: Trying to use a non-local installation of Hardhat, which is not supported

Below is a short list of my setup until I stumble upon the HH12 Hardhat Error that I keep getting:
mkdir wave (Name of my directory)
cd wave
npm init -y
npm install —save-dev hardhat
npx hardhat
Choose sample project
6a. Hardhat project root (Select)
6b. Add .gitignore
Say yes to everything
install the remaining dependencies: npm install --save-dev #nomiclabs/hardhat-waffle ethereum-waffle chai #nomiclabs/hardhat-ethers ethers
npx hardhat accounts (to see all the different accounts)...
...And then it fails here! An HH12 Hardhat Error Message: "Hardhat is not installed or installed globally. You tried to run Hardhat from a global installation or not installing it at all. This is not supported. Please install Hardhat locally using npm or Yarn, and try again." (https://hardhat.org/errors/) [BTW, these 2 lines are the ONLY docs on this error on Hardhat!].
Any suggestions?
I have tried the following possible 'fixes' to sidestep this error but to no avail:
Updating most current version of node
Restarting my PC (About 17 X now as of this writing)
Using GitBash (Instead of Powershell)
Asking mods in Hardhat Discord (None) and other Discords
Opening the Hardhat docs (And the Tutorials!!) for answers... None!
StackExchange - There's literally only 1 other person who ALSO had this problem here! But the answers here are not the solution. (Have DMd that person but no reply as of yet).
So can anyone out there help?
I believe I finally figured out the solution (at least what worked for me):
I dropped back 2 directory levels from where I was for my root project and started again there.
I updated my Node version to 16.

Yarn errors when running (context: Setting up WunderGraph GraphQL instance)

Context:
I am attempting to run the demo from Wundergraph on a work computer. When I get to installing Wundergraph with Yarn, it fails. The Wundergraph error is.
Internal Error: Error when performing the request
at ClientRequest.<Anonymous> (C:Users\{user name here}\AppData\Roaming\npm\node_modules\corepack\dist\corepack.js :3927:20)
at ClientRequest.emit (noe:events:390:28)
at TLSSocket.socketErrorListener (node:_http_client:447:9)
at TLSSocket.emit (node:events:390:20)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
With the socket issue, I am guessing there is a proxy or some other security issue on the client computer. I have successfully run the following on a separate, personal computer:
yarn global add #wundergraph/wunderctl#latest
No variation of yarn commands work on the work, computer (fails with any of the following):
yarn
yarn global add #wundergraph/wunderctl#latest
To eliminate possibilities:
On my local machine, yarn will not properly add path to wunderctl, which means searcing out the .exe to get the samples installed. This is a minor oversight in the demo, as the demo now works.
Does not matter if the command prompt is run as me or as administrator. It fails either way.
Fails on VPN and off, so VPN not the issue.
I can get things installed with NPM, but that appears to successfully install the .js files from Wundergraph and not the .exe. I am thinking this might be a clue.
I am going to work with others who say they have it installed and see how they did it, but that won't happen until next week. As I am contract and they are employees, it could end up being additional restrictions.
As this does it with yarn, as well as yarn {install command here}, I am guessing it is some check yarn does every time, or permissions on the yarn files themselves.
I know this is a long shot, but hoping someone encountered this and has found a way down the Rabbit Hole and then back out of wonderland. My fear is having to go full manual, edit the sample files heavily to eradicate yarn (for npm, most likely), have to wait until Wundergraph goes open source and grab the bits, work strictly from command line, or all of the above.
I have done a lot of searching for an answer before coming here.
I had the same problem with another package, with exactly the same error call stack.
First I updated NodeJS to the latest stable version 16.13.1 (I had 14.16.0). After that yarn showed signs of life:
yarn install v1.21.1
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
But then it failed with
RequestError: connect ETIMEDOUT {ip address}:443
at ClientRequest.<anonymous> (node_modules\got\source\request-as-event-emitter.js:178:14)
at Object.onceWrapper (node:events:510:26)
at ClientRequest.emit (node:events:402:35)
at ClientRequest.origin.emit (node_modules\got\node_modules\#szmarczak\http-timer\source\index.js:37:11)
at TLSSocket.socketErrorListener (node:_http_client:447:9)
at TLSSocket.emit (node:events:390:28)
That ip address was indeed unreachable due to a routing problem, after I fixed that all went well.

OSX fix Selenium Chromedriver launch error spawn Unknown system error -86 Bad CPU type in executable?

Suddenly on the afternoon of January 6, 2021, my Selenium Protractor tests under OSX stopped working with the mysterious error
spawn Unknown system error -86
I did some research and discovered that error number 86 is the same as
Bad CPU type in executable
and ran the following to compare the cpu architecture of my chromedriver binary to my system:
% file chromedriver_87.0.4280.88
chromedriver_87.0.4280.88: Mach-O 64-bit executable arm64
% uname -a
Darwin kobl179273m 19.6.0 Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64 x86_64
% uname -p
i386
How can I fix the chromedriver binary used by my Selenium so that it will run on my Intel x64 mac and clear the "system error -86" or "Bad CPU type" message?
The issue is described in https://github.com/angular/webdriver-manager/issues/476.
This has been now fixed in 12.1.8 so just update to that webdriver manager.
For most users this can be accomplished with
npm uninstall protractor && npm install protractor
Edit: this answer should be considered deprecated now that the underlying bug in webdriver-manager has been fixed. A better solution would be to upgrade to the newest version of webdriver-manager. The answer below may be useful if people need to use an older version of webdriver-manager which still has the bug.
As per Deepak Srinivasan's comment above, this error is caused by https://github.com/angular/webdriver-manager/issues/476
Root Cause:
The ChromeDriver team added "_m1" to the end of the filename for their Apple Silicon ARM builds of Chromedriver -- but both the Silicon and Intel versions of chromedriver have "mac64" in the filename, and the version number is exactly the same. This causes webdriver-manager to always download the Silicon build of Chromedriver, even on Intel macs. As a general solution, simply avoid using the chromedriver that has _m1 in its filename if you are on an Intel mac.
Solution 1: Downgrade to Chrome 86.0.4240.198 and Chromedriver 86.0.4240.22. These versions work together and are the most recent versions prior to the new and problematic support for Silicon ARM
Chrome 86 download page:
https://google-chrome.en.uptodown.com/mac/download/2920124
Disable auto-updates in Chrome: https://superuser.com/questions/1359017/how-do-i-disable-automatic-updates-of-google-chrome-on-mac-os-x
Chromedriver 86: https://chromedriver.storage.googleapis.com/index.html?path=86.0.4240.22/
% webdriver-manager update --versions.chrome=86.0.4240.22
Solution 2: Modify the webdriver-manager npm package to point to the correct chromedriver (thanks to ciekaway from the angular github issue page for this fix)
Modify the following file
node_modules/webdriver-manager/built/lib/files/file_manager.js
or, if using protractor
node_modules/protractor/node_modules/webdriver-manager/built/lib/files/file_manager.js
Near the top of the downloadFile method around line 166, add the following line to remove "_m1" from the name of the file:
fileUrl.url = fileUrl.url.replace(/_m1/, '');
It needs to be after the beginning of the .then block that starts with
binary.getUrl(binary.version()).then(fileUrl => {
it also needs to be before the next reference to fileUrl.
For example:
binary.getUrl(binary.version()).then(fileUrl => {
binary.versionCustom = fileUrl.version;
fileUrl.url = fileUrl.url.replace(/_m1/, '');
let filePath = path.resolve(outputDir, binary.filename());
Note that this solution is temporary. It will be overwritten by an npm install. The Chromedriver and/or the webdriver-manager team will probably fix this issue, at which point you should clear the modified version of your webdriver-manager and download the fix from npm.
For macOS Catalina Version 10.15.6 (19G73)
In my case I was working with Rails and Capybara for feature tests. What worked for me was
First, find the actual chromedriver location running:
which chromedriver
# Which returned:
/Users/alex/.webdrivers/chromedriver
Then, install chromedriver via Homebrew:
brew install chromedriver
Then, remove old chromedriver reference found at previous location with:
rm /Users/alex/.webdrivers/chromedriver
Now, link the old chromedriver reference to the one installed with brew:
ln -s /usr/local/bin/chromedriver /Users/alex/.webdrivers/chromedriver
Then, open Finder app, then click on Go menu and then click Go to folder ... option, and enter this route:
/usr/local/Caskroom/chromedriver/
There you should see a folder with the chromedriver version you have installed, something like this:
88.0.4324.96
Enter that folder and you should see the chromedriver binary file.
Right click on it, and click on Open
Now, you should get a terminal window popping up with the output:
Last login: Sun Jan 31 12:29:15 on ttys001
/usr/local/Caskroom/chromedriver/88.0.4324.96/chromedriver ; exit;
  ~  /usr/local/Caskroom/chromedriver/88.0.4324.96/chromedriver ; exit;
Starting ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b- refs/branch-heads/4324#{#1784}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Finally, press Ctrl+C to stop the execution and quit the terminal window.
Now, you should be able to run capybara tests.
npm uninstall protractor && npm install protractor
If you use webdrivers gem, upgrade it:
bundle update webdrivers

Creating New Shared NativeScript Project doesn't work

When I run the following:
ng new --collection=#nativescript/schematics myProject --shared
It does not work. I have installed the schematic and everything according to the docs but that command does nothing. Any ideas?
I have followed the documentation here:
https://docs.nativescript.org/angular/code-sharing/creating-a-new-project
I checked for an invalid .angular.json but there is not one in my home directory.
I am running angular 6.0.3
There are no errors, I run the command it waits about 5 seconds and just returns doing nothing.
I found that I was running the wrong version of the Angular CLI, but I have upgraded and now when I run the build for iOS I get the following:
Error: Cannot connect to device socket.The error message is Device socket port cannot be found.
at Errors.fail (/Users/jonathan/.nvm/versions/node/v10.8.0/lib/node_modules/nativescript/lib/common/errors.js:125:28)
at Errors.failWithoutHelp (/Users/jonathan/.nvm/versions/node/v10.8.0/lib/node_modules/nativescript/lib/common/errors.js:135:21)
at AppDebugSocketProxyFactory.<anonymous> (/Users/jonathan/.nvm/versions/node/v10.8.0/lib/node_modules/nativescript/lib/device-sockets/ios/app-debug-socket-proxy-factory.js:105:38)
at Generator.throw (<anonymous>)
at rejected (/Users/jonathan/.nvm/versions/node/v10.8.0/lib/node_modules/nativescript/lib/device-sockets/ios/app-debug-socket-proxy-factory.js:5:65)
The Emulator opens and the app gets installed on the emulator but crashes as soon as it starts. I have tried to make this work with just a hello world app and it works correctly. But when using the shared flag it does not work.

Angular e2e testing without chromedriver

I am working on angular application e2e tests in very closed and secure environment, where it is not allowed to install chromedriver. It is Windows 7 with IE11 installed.
Command:
npm install chromedriver --save-dev
results with:
> chromedriver#2.31.0 install C:\_LocalWorkspace\Projects\SomeProject\node_modules\chromedriver
> node install.js
Downloading https://chromedriver.storage.googleapis.com/2.31/chromedriver_win32.zip
Saving to C:\Users\someuser\AppData\Local\Temp\chromedriver\chromedriver_win32.zip
ChromeDriver installation failed Error with http request: Error: connect ETIMEDOUT 172.217.21.208:443
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN app#0.0.1 No repository field.
npm ERR! Windows_NT 6.1.7601
What are my options for e2e tests in this circumstances?
EDIT1:
The problem can be described in other words. The environment that I am working in is closed for direct binary downloading. I am working for a client that has such policy and I can not do anything about that. I am also not allowed to install chrome browser so I have to use internet explorer. Therefore, only available webdrivr is iedriver. ( Please correct me if I am wrong )
My main problem is to install all requirements to make protractor works. It is like I have no Internet connection, but just for binaries. Most of the npm dependencies can be installed normally.
Like:
npm instal webdriver-manager which works,
but
node ./node_modules/protractor/bin/webdriver-manager update fails to download these three files:
https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
https://chromedriver.storage.googleapis.com/2.26/chromedriver_win32.zip
https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-win64.zip
I have an option (from the client) to download files in isolated environment let them through security check and then use them. I did that and I have placed those 3 files in SomeProject\node_modules\protractor\node_modules\webdriver-manager\selenium directory.
Then I have tried to run node ./node_modules/protractor/bin/webdriver-manager update again, hoping that it will skip the download and continue with the normal process steps, extracting etc. But it did not, again it failed to download with the same message.
Then I have extracted the zip files manually.
At this point I am not sure, does node ./node_modules/protractor/bin/webdriver-manager update need to do more things than downloading and extracting. Because it has terminated on download, and I did it manually but how can I know what it would do after if the download was successful?
Anyway, I tried npm run e2e command (which is starting my protractor tests) with extracted binaries in place.
The result was:
[13:24:07] I/local - Starting selenium standalone server...
[13:24:07] I/launcher - Running 1 instances of WebDriver
[13:24:11] I/local - Selenium standalone server started at http://53.150.192.128:58001/wd/hub
[13:24:11] E/launcher - The path to the driver executable must be set by the webdriver.ie.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver. The latest version can be downloaded from http://sel
enium-release.storage.googleapis.com/index.html
From error message it is clear that I should download the latest version of iedriver from here as it is described here
I have chosen the latest version, currently 3.4
http://selenium-release.storage.googleapis.com/index.html?path=3.4/
that looks like this:
I took the first link IEDriverServer_Win32_3.4.0.zip downloaded it and extract it in SomeProject\node_modules\protractor\node_modules\webdriver-manager\selenium
But the problem with the same error message still exists. Am I placing it in correct target directory? Should I download maybe some other file from the image?
Please advise how can I install iedriever and run protractor tests.
EDIT2:
Also, the problem can be generalized and put like. How to install protractor dependencies by downloading them manually?

Resources