Protractor - Getting error "Cannot find module ../lib/cli.js - node.js

I've been working with Protractor for a couple days now, but ran into a problem today on my work machine with node. So I tried doing a 'brew uninstall node', but hit an error, and since then have not been able to get my protractor tests to run.
I've gone through many steps, including removing node manually and reinstalling, as well as attempting to reinstall protractor. Currently, the error I'm getting when I try to run any of my tests is 'Cannot find module ../lib/cli.js'.
I verified that I have a 'protractor' directory in ~/.node/lib/node_modules, and there is a 'cli.js' file in that folder's 'lib' directory. I've tried installing protractor globally, so there is also the same 'protractor' folder in /usr/local/lib/node_modules, and it too has a lib folder that contains a 'cli.js' file. I've also tried installing a 'node_modules' folder into my project directory, and it too has a lib/cli.js file, so I'm not really sure where it could be missing that file.
I'm running OS X 10.10. If I run a 'which node' command, I get back '/usr/local/bin/node' and /usr/local/bin is in my PATH. Also, my NODE_PATH variable points to /usr/local/lib/node_modules.
I'm not sure if this is needed for this or not, but here is one of the test cases I'm attempting to run that throws the error:
describe('CreateUser', function() {
signupPage = require('./Pages/SignupPage.js');
loginPage = require('./Pages/LoginPage.js');
dataHelper = require('./Library/DataHelper.js');
var ptor;
var plistPath = '/Users/Heath/Documents/Scripts/Protractor/ProtractorFramework/TestRunData/CurrentTestRun.plist';
var userName = dataHelper.updateUserName(plistPath);
beforeEach(function(){
browser.ignoreSynchronization = true;
//ptor = protractor.getInstance();
// ptor.ignoreSynchronization = true;
});
it('It should add new user', function() {
browser.driver.get(loginPage.url);
loginPage.createStudyAbroadAccountLink.click();
signupPage.firstNameTextBox.sendKeys('blah');
signupPage.lastNameTextBox.sendKeys('whatever');
signupPage.emailTextBox.sendKeys(userName);
signupPage.facultyMemberDropdownItem.click();
signupPage.maleRadioButtonItem.click();
signupPage.passwordTextBox.sendKeys('1-Council');
signupPage.passwordConfirmationTextBox.sendKeys('1-Council');
signupPage.agreeCheckbox.click();
signupPage.signupButton.click();
browser.sleep(6000);
// ptor.sleep(6000);
expect(browser.getCurrentUrl()).toEqual('https://www-qa.ciee.org/myaccount');
});
});
Any help would be appreciated. I'm starting to think I'm not going to get protractor tests running on this machine again.
Thanks,

Well it figures.I've been working on this for 10 hours, and I found out what the issue was 5 mins after I posted. If I just called protractor without a full path it was running it from /usr/local/bin. There is a lib folder in 'local' that has a cli.js file, so that still confuses me a bit, but I tried running the test with the project's 'protractor' and received an error about not being able to start webdriver. (even though I had an instance running already)
The project's folder was missing a selenium directory, so I copied that into it, and all is working now. I'm still confused why the default protractor wasn't working, but at least I can run the tests now.
I'm pretty sure this is all due to me trying to perform a 'brew uninstall node'. After getting an error on that command, it broke something protractor related.
Thanks,

Related

TypeError: parse is not a function

As I had installed the Font Awesome dependencies to my app and tried to run npm start right after to test it out, I received this error and it has been super brutal & difficult to resolve.
$ npm start
> portfolio#0.1.3 start
> react-scripts start
~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/css-select/lib/compile.js:31
var token = parse(selector, options);
^
TypeError: parse is not a function
at compileUnsafe (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/css-select/lib/compile.js:31:14)
at Function.compile (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/css-select/lib/compile.js:20:13)
at new Selector (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/renderKid/styles/rule/Selector.js:13:26)
at new Rule (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/renderKid/styles/Rule.js:10:21)
at StyleSheet.module.exports.StyleSheet._setSingleRule (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/renderKid/styles/StyleSheet.js:42:14)
at StyleSheet.module.exports.StyleSheet._setRule (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/renderKid/styles/StyleSheet.js:33:12)
at StyleSheet.module.exports.StyleSheet.setRule (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/renderKid/styles/StyleSheet.js:22:14)
at Styles.module.exports.Styles._setDefaultStyles (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/renderKid/Styles.js:34:25)
at new Styles (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/renderKid/Styles.js:30:10)
at RenderKid.module.exports.RenderKid._initStyles (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/RenderKid.js:53:27)
I've checked my package.json file and have my start scripts assigned correctly. I have been at it with this error for nearly a day already.
I have also checked on all my dependencies to make sure they were not outdated. Everything is up to date and still seems to be getting the error.
I have even tried to revert back a few steps from my commits but unfortunately still running into this error so I believe it has to to something with the modules
Try to use an older stable version instead of the new version.
It worked for me..
I changed the version in packet.json and removed node_module folder and
then use npm install again

Azure Function 'unable to find module' after following installation instructions

I'm trying trying to use a node module inside my Azure Functions project. I've tried following these instructions several times but still can't use the module I'm trying to bring in.
After bringing in my package.json and running npm install, I can see the node_modules folder (actual modules are located in node_modules/.staging). Upon restarting the function and trying to run it, I get Error: Cannot find module '_____'.
I'm following the instructions correctly. Any suggestions on how to get the modules to work?
You did everything correctly, after npm install, please wait for some time. Modules being in ./staging folder means the installation is still in progress.
You will see added packages prompt in console after the installation is finished.
Update--Avoid long time waiting for module install.
As #brettsam mentioned in comment, with azure-functions-pack tool(also a module), we can place all the modules in a single file, no need to install online and wait. You can search for your function name to find your function scripts if you want to edit after publication.

Grunt only runs default task

Using OSX Maveriks, iTerminal, zsh.
Problem: Grunt runs only the default task regardless of the task you specify.
Problem: It only happens in 1 computer.
What can be the reason for grunt not to run but the default task. I've been working with Grunt for a long time now and we use it at the company I work at. Everything has been working perfectly smooth except for 1 single coworker that when he runs grunt myTask is like if he were running just grunt, even if I run a made up task like grunt myNotExistentTask it ignores it and again looks like it runs grunt.
I did check for stupid errors:
Checked that I'm accessing the same project folder (multiple times).
I deleted the default task to see if it complained and it does.
I checked that the Gruntfile was not throwing errors. Then I forced to throw errors to see if it would complain, and it does.
Runned npm install.
Check both bashrc and zshrc for a grunt command or something.
Obviously grunt is accessible.
Runned it in the default terminal and in iTerm.
"Have you try to turn it on and off?" Yes I did restar the laptop.
I tried with multiple coworkers laptops and it only happens in the one laptop.
I did not have time to (but I will check for these):
test creating a simple Gruntfile somewhere else in his laptop, but I have a weird feeling that it would behave the same way.
reinstall grunt. Would that help?
grunt --version or others for that matter, I assumed that it has the specified version in the package.json.
we are using:
"grunt-cli": "^0.1.13",
"grunt": "^0.4.4"
The code is not causing the issue here because every computer runs it but one. I can't show the actual code but I can give you the boilerplate just in case there is some mysterious thing I don't know about:
module.exports = function(grunt) {
grunt.initConfig({
pkg : grunt.file.readJSON("package.json"),
someTask : {
options : {
},
target1 : {
}
}
});
grunt.loadNpmTasks("dependency1");
grunt.loadNpmTasks("dependency2");
grunt.loadNpmTasks("etc");
grunt.registerTask("default", function () {
// creates a server with one of the dependencies
});
grunt.registerTask("w", function () {
// creates a watch with one of the dependencies
});
};
There is a reason behind why we are not simply doing something like grunt.registerTask("default", [".."]). Basically, our projects are too big and we need to change settings for each task to increase performance (e.g. not to watch too many files, etc).
I googled this different ways and couldn't find anything about this happening before. Any ideas are welcomed.
Edit
I forgot to mention that he has been working with the project for a while, we just recently noticed because he never needed to use any other task but the default task until a few days ago when he needed to use a different task, in summary, we don't know when or why it started.
After:
Deleting and cloning the repo.
Deleting npm_modules.
Reinstalling everything.
Creating an isolated project to test this issue.
and failing, we checked for the paths to grunt thanks to a comment by #XavierPriour
Using zsh with iTerm:
➜ folder git:(branch) which grunt
/usr/local/bin/grunt
➜ folder git:(branch) type -a grunt
grunt is /usr/local/bin/grunt
grunt is /usr/bin/grunt
We deleted the extra grunt binary:
➜ folder git:(branch) cd /usr/bin
➜ bin sudo -rm grunt
And everything started working correctly. I assume the issue is he installed grunt globally instead of just grunt-cli, although I'm not sure.
The most popular answer to this question shows the dos and don'ts of how to install grunt.

Cannot find module 'assetmanager'

I'm trying to run the MEAN stack on windows. I've installed all the pre-requisites (I think) but when I try to start the server via the gulp command I get the error:
Error: Cannot find module 'assetmanager'.
IMAGE:
I have tried running npm install assetmanager which run fine but I still get this error.
This is my first time trying to run node on a machine (I should have used a linux box) so go easy on me as I am learning :-).
Any and all help appreciated.
David
I had exactly the same problem on Linux Mint 17.2.
The failing way: This was my first project that I'd generated and I don't think I had all the dependencies installed before I ran the init command (g++ was missing).
I tried the npm install assetmanager command as you did and then install worked. Running gulp after this, it got further but this time I was missing mongoose. I installed that then it couldn't find .../config/env/all so I sylinked the default.js config. Then running gulp again, errorhandler was missing. I figured it shouldn't be this hard so...
The working way: I deleted that failure of a project and init'd a new one and it worked. Unfortunately I'm not sure if the init didn't work the first time but I missed the error/warning or something else caused it. All I can recommend is try creating another project and see if that works.

Issues installing swiper.js (node.js/grunt noob)

Having issues getting swiper.js to work. Requires grunt/bower. I'm completely new to js generators and am only able to get through about half the walkthrough before running into issues.
When I type $grunt dist into terminal, I get the following response: -bash: dist: command not found
What step am I missing?
Followed the idangerous steps to the letter: http://www.idangero.us/sliders/swiper/plugins/scrollbar.php
I have most often see "X command not found" for one of the following reasons:
The project's Grunt dependencies aren't installed or aren't installed properly
Your Gruntfile is mis-configured or missing
To fix this, first make sure there is a package.json file in your project. This will tell the npm what dependencies the project has and install them accordingly (assuming the package.json file is also configured correctly).
Next, make sure you have installed grunt correctly.
If you're still having issues, open your Gruntfile and search for:
grunt.registerTask('dist
This will show where the "dist" task is being defined. If you for some reason don't find it, then there's your problem. If you do find it, then check the proceeding commands inside square brackets that look like this:
grunt.registerTask('dist', ['clean', 'dist-css', 'copy:fonts', 'dist-js', 'dist-docs']);
'clean', 'dist-css', etc. are all other tasks defined in the Gruntfile, and there could be an issue with those as well.
If there's an issue with your package.json or Gruntfile, then trying re-installing the project with bower and repeat the above steps to ensure that it's not an issue on your end.
If it's not, then something is probably wrong with the author's source code.

Resources