Protractor local and global installations behaving differently - javascript

This is a rough one. Two fellow developers and I have been working for nearly 24 hours on this. I have a conf.js that I can navigate to in Terminal and then run protractor conf.js (using the globally installed copy) and it runs perfectly. One at a time, each green dot appears after each successful test, and it takes about 80 seconds. Here's where it gets tricky.
If I force the local installation of Protractor to run by executing (path of project)/node_modules/protractor/bin/protractor conf.js then it fires up, shows me several green dots all at once, then throws an error about not being able to hook into angular. This is causing trouble with integrating with our build, since grunt looks for and uses the local copy of Protractor.
To further complicate matters, one of the two other developers can pull down my repo and run the local protractor installation on my conf.js no problem. It works 100%.
Error while waiting for Protractor to sync with the page: "window.angular is
undefined. This could be either because this is a non-angular page or because your
test involves client-side navigation, which can interfere with Protractor's
bootstrapping. See http://git.io/v4gXM for details"
We've checked all of the following:
Both local and global installations of Protractor are the same version, installed with npm.
Richards-MacBook-Pro:protractor richardpressler$ npm ls protractor
wear-test-web-framework#0.0.1
/path_to_project/wear-test-track0
└── protractor#3.1.1
Richards-MacBook-Pro:protractor richardpressler$ npm ls -g protractor
/usr/local/lib
└── protractor#3.1.1
Selenium is up-to date. We have run both (path to project)/node_modules/protractor/bin/webdriver-manager update as well as webdriver-manager update to update both local and global selenium server installations
I've tried firing up Selenium separately and then pointing Protractor to it so that I can see the output and it looks great when I run the conf.js using the global protractor (protractor conf.js), showing several [Executing] statements each followed by a [Done] statement. However, when I run the local protractor binary with (path to project)/node_modules/protractor/bin/protractor conf.js, I see that Protractor was able to connect to the Selenium instance, but didn't do much afterword:
When the protractor output looks like this:
Richards-MacBook-Pro:protractor richardpressler$ ../../node_modules/protractor/bin/protractor conf.js
Using the selenium server at http://127.0.0.1:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Started
.......................
The Selenium server only outputs this:
10:35:47.612 INFO - Selenium Server is up and running
10:35:49.479 INFO - Executing: [new session: Capabilities [{count=1, browserName=chrome}]])
10:35:49.487 INFO - Creating a new session for Capabilities [{count=1, browserName=chrome}]
Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 34848
Only local connections are allowed.
10:35:50.516 INFO - Done: [new session: Capabilities [{count=1, browserName=chrome}]]
10:35:50.532 INFO - Executing: [set script timeout: 11000])
10:35:50.537 INFO - Done: [set script timeout: 11000]
Has anyone had similar misbehavior by Protractor when comparing the global, command-line version and the locally installed version in the project?
Thanks

Turns out all of the dependencies for protractor, grunt, selenium, etc. were in devDependencies so when I initially ran npm install it simply didn't install all of the sub-dependencies for those packages. If I move them into dependencies in the package.json, then re-run npm install, it works like a charm. Alternatively, running npm install --dev with those dependencies in devDependencies works fine too.
More info on the differences between dependencies, devDependencies, and peerDependencies can be found here: What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?

Related

Node cannot find path in node_modules / 'react-scripts' is not recognized as an internal or external command

I'm on windows 10
When I run:
npm run start
or
npm start
I get an error:
npm start
> app-test#0.1.0 start
> react-scripts start
'react-scripts' is not recognized as an internal or external command,
operable program or batch file.
What I already tried:
npm ci
remove node_modules and reinstall project
npm audit fix
run command from elevated PowerShell (as admin)
Uninstall Node v.18 win NVM and reinstall common Node installation LTS v.16
Check if react scripts is on dependencies section in package.json - and it's of course there.
Recreate project itself and also create a fresh new React project with npx create-react-app
Clearing npm cache
Nothing's helped me.
BUT This project runs fine WHEN I explicitly tell the node path to subfolder with a script:
app-test> node node_modules/react-scripts/scripts/start.js
Compiled successfully!
You can now view app-test in the browser.
Local: http://localhost:3000
On Your Network: http://192.168.91.1:3000
Note that the development build is not optimized.
To create a production build, use npm run build.
webpack compiled successfully
What's interesting that an old React projects also resided in the parent folder starts normally even I renew node_modules in these projects doing them npm i or npm ci
But any time I try to create and start new React app command npm start fails
UPD1: Tried to create-react-app on any other drive or folder. And it's running ok.
So culprit seems permissions policies in my common working directory ?
UPD2:
I resolved a problem though still have no clear idea who was actually the really culprit of this bug.
I copied all my parent developer folder with all code examples to another drive, then tried to create react app there and out of the blue it worked fine at then new location.
Also I removed this original folder from the drive where it used to be. And do git clone "..." at this directory< recreating the exact structure as it was before all experiments.
Then I tried create-react-app exactly at that location as I've unsuccessfully tried before swapping folders and it was OK !
Tried couple of time with different folder location within parent directory and all sill working fine now !
I remembered now I already have such bug before. And I had to reinstall Windows that time.
I also want to mention that I also have another machine with Windows, another one with Linux and had also laptop with an OSX so I can ( or could) push to this very git repository from any of these computers.
Suggestion of somebody who have any idea, why this bug was happening repeatable would be highly appreciated.
Thanks.

Javascript issue installing npm packages (nodemon, express)

I'm new to js and trying to setup a simple project with express and nodemon via npm.
However, installing these packages does give me multiple errors (see below).
I am on Win 10, using the PowerShell & Atom IDE. Project is saved on Google Drive.
"Calc.js" is simply the name of my project.
I have node & npm installed and restarted pc multiple times before.
Then I set up the npm init
I begin to install the first package and get this error:
I try to install express, but get the same result, adding -g also does not make a difference. Now I install "ci", which works for some reason.
Now I have the node modules folder in my project, try to install express again, and it seems to kinda work (got the files in the node_modules folder).
However when I try to run the calc.js via "node calc.js" it
does not work.
Already tried out many things and even accidentally made it work, then tried to reproduce it and failed. Would be super happy for some help.

build dev failed: Cannot set property 'fileSystem' of null

I am trying to run an Ionic 2 Application. I am getting following error on running ionic serve
build dev failed: Cannot set property 'fileSystem' of null
The complete log is as below:
λ ionic serve
> ionic-hello-world# ionic:serve D:\ionic
> ionic-app-scripts serve
[18:11:23] ionic-app-scripts 0.0.47
[18:11:24] watch started ...
[18:11:24] build dev started ...
[18:11:24] clean started ...
[18:11:24] clean finished in 6 ms
[18:11:24] copy started ...
[18:11:24] transpile started ...
[18:11:28] transpile finished in 4.15 s
[18:11:28] webpack started ...
[18:11:28] build dev failed: Cannot set property 'fileSystem' of null
[18:11:28] dev server running: http://localhost:8100/
[18:11:28] copy finished in 4.39 s
[18:11:28] watch ready in 4.44 s
Update your ionic app scripts to the latest version. It is 1.0.0 for RC5 release.
npm install #ionic/app-scripts#latest --save-dev.
As suggested, check the package.json from here.
Run npm install
This worked for me:
In your project go to yourProjectname\node_modules\#typesoject
Then install
$ npm install pouchdb #types/pouchdb
You can now use
import PouchDB from 'pouchdb';
as explained here here
I also faced this issue for Ionic2 application. When i tried to run the application in ripple browser it was telling "You're almost ready! If you're seeing this page, then you still need to install the NPM Task Runner extension for Visual Studio and run this app again. You can download the extension from:".
I struggled a lot to resolve the issue i was using visual studio 2015 Update3.
Finally i got a solution issue was with ionic "#ionic/app-scripts".
To resolve the issue i fallowed the below steps.
1] execute command "npm uninstall -g ionic" in Command Prompt.
2] Update the version of #ionic/app-scripts to 1.1.4 i.e "#ionic/app-scripts": "1.1.4" in package.json file and Save the file.
3] execute command "npm install -g ionic" in Command Prompt.
it will give some warning don't need to wary about it.
4] again i have done Restore Packages by right clicking on the packages.json file.
5] next go to view menu in the visual studio and select other windows from there select Task Runner Explorer.
6] Right Click on ionic:build select Binding > Before Build(it will make the all the ionic component to build first before deploying to www directory.
Make sure you have deleted the node_module folder before starting these steps.
That's all everything got set to me application started working fine.
I hope it will help some one.
Second solution is instead black project take sidemenu project even if you fail do the above mentioned steps and restart the visual studio and create new project with sidemenu it will work fine.

Automate Protractor / Selenium / Webdriver command

How can i start my localhost server with node app.js, run webdriver-manager start, and protractor conf.js in one command.
Each of these commands take place in a different folder.
I want to streamline this process.
I have a written an alias that executes each command in their respective folders.
Problem is, each of these commands launch a server, and the terminal enters non-canonical mode which causes an issue.
I have tried adding & to the end of each command, but this did not work.
Solve it via a task management tool like grunt or gulp.
Here is the list of plugins that might be useful in your case:
grunt-protractor-runner
grunt-contrib-connect
grunt-contrib-watch
See also:
Testing With AngularJS Part 5: Protractor and Grunt
Integrating Protractor with Yeoman via Grunt

Grunt.js Installation Issue - Command Not Found

I'm trying to get grunt.js set up on my work machine. Now I've managed to get it set up at home, so I pushed my repository, then cloned it on my work machine, however despite troubleshooting this to death I've always run into the same issue when I come to try and run the command on my work computer;
sh.exe": grunt: command not found
So some background and explanation;
I'm using Aptana 3.0 and running all my commands through the terminal. (This applies to my home and work computer)
I cloned the "working" repository and put it in a folder on my work machine, so I have my package.json and gruntfile.js files inside said directory. These work fine on my home computer and I am able to run the watch task set up in my gruntfile.js successfully at home.
I've run npm install grunt-cli -g and npm install inside my project on my WORK computer and installation has been successful each time. My only error messages on either are a lack of description and a repository field which, to my knowledge these aren't mandatory?
The node modules folder inside my repository indicates I have the following installed (as per my package.json)
grunt
grunt-contrib-compass
grunt-contrib-uglify
grunt-contrib-watch
matchdep
Now I'm pretty green to this command line stuff, so I may have overlooked something very obvious but I feel like I've tried every guide going to get this thing to work.
Despite running through the getting started steps/installing grunt documentation repeatedly, it seems no matter what I do the terminal will not pick up grunt as a recognized command.
Am I stupid or is this some other issue?
EDIT 1: contents of my package.json:
{
"name" : "xxxxxxxxx",
"version" : "xxxx",
"dependencies" : {
"grunt":"~0.4.1",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-compass": "~0.5.0",
"grunt-contrib-uglify": "~0.2.2",
"matchdep": "~0.1.2"
}
}
This is happening because you are using the Aptana Terminal, which needs the PATH variable to work out what is meant by grunt etc. A normal cmd prompt would work fine with the command npm install grunt-cli -g but in this context the terminal is unaware of what grunt is.
As per the following existing answer, you need to set up your Windows PATH variable to make the Aptana Terminal aware of the npm directory: https://stackoverflow.com/a/19137584/463205
C:\Users\Username\AppData\Roaming\npm
Closing the terminal and reopening it after setting the PATH correctly should enable you to run the command successfully.
Try to run
npm install grunt-cli -g
On your home computer.
-g means - install Grunt globally (not in the project node_modules folder), so it'll add grunt command to the bin folder which is used by nodejs console ( and you need to run node.js command prompt, not just arbitrary cmd)

Categories

Resources