Cannot run unit tests on angular-seed - angularjs

I followed the instructions on Running Unit Tests on the Angular Seed Project, but I get the following error:
scripts/test.sh: line 9: scripts/../node_modules/karma/bin/karma:
No such file or directory
Any ideas?

I think I found the issue.
The README says the following:
Requires node.js, Karma (sudo npm install -g karma) and a local or remote browser.
But I checked at scripts/test.sh:
$BASE_DIR/../node_modules/karma/bin/karma start $BASE_DIR/../config/karma.conf.js $*
So it looks like test.sh is looking for karma in the base angular-seed directory.
I did the following:
$> cd angular-seed-master
$> npm install karma
$> karma init
[... followed instructions ...]
$> scripts/test.sh
And it worked.
Note: It seems the README in Angular Seed Project is outdated as this Issue in Github from 2 months ago explains. This issue should go away soon.
Karma should be loaded from the path - not a relative directory #125
+1, without this the README setup instructions no longer work.
Alternatively the README could be updated to account for local installation as in angular#132 Though note though that package.json also needs a "version" field which is causes npm to error out on npm install for me when installed locally.

Related

create-react-app: Template was precompiled with an older version of Handlebars

I just installed create-react-app package following the instructions on https://github.com/facebookincubator/create-react-app.
After that I've followed the instructions and created a "myapp" app:
$ create-react-app --version
1.0.4
$ create-react-app myapp
Creating a new React app in /home/...mydir.../myapp.
Installing packages. This might take a couple minutes.
Installing react-scripts...
After the list of installed packages I've got:
Success! Created myapp at /home/...mydir.../myapp
Inside that directory, you can run several commands:
npm start
Starts the development server.
npm run build
Bundles the app into static files for production.
npm test
Starts the test runner.
npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd myapp
npm start
Happy hacking!
Ok, but when I'm running the server I've got the following message on browser console:
Template was precompiled with an older version of Handlebars than the current
runtime. Please update your precompiler to a newer version (>= 4.0.0) or downgrade
your runtime to an older version (>= 2.0.0-beta.1).
I've verified the handlebars version :
$ npm ls|grep handlebars
│ │ └─┬ handlebars#4.0.6
I've also tried to set the handlebars version on package.json under "devDependencies" and "dependencies" but that didn't work.
Any ideas on how to solve this?
This is a bug in Code Climate Chrome extension.
If you uninstall it, the error will go away.

generator-angular - You don't seem to have generator with the name angular installed

So I wanted to take a look at the latest generator, seeing as they use gulp now.
Anyhow, after updating everything twice, reinstalling node, deleting npm-cache and so on, when I do yo angular the following happens:
The generator starts and asks me the usual questions (grunt/gulp, sass? etc)
I can choose the angular modules I want (ng-animate, etc.)
It begins to generate the app skeleton
Then it crashes (before running npm install / bower install apparently), with the not very helpful message
Error angular
You don't seem to have a generator with the name angular:common:C:\Users\myuser\AppData\Roaming\npm\node_modules\generator-angular\app\index.js installed.
The directory is there (generator-angular). The sub-directory is there (generator-angular/common). The index.js exists. I have installed and updated the generator and all the dependencies like 5 times now.
Now, the strange thing is, I tried older versions of yo and also generator-angular and they all fail with the same error message, so it's very likely something on my end, but I can't figure it out.
I've found older threads of this issue here on StackOverflow but all were solved by updating or fixing the path. None of that helped me :(
Here is the yo doctor output
Yeoman Doctor
Running sanity checks on your system
√ Global configuration file is valid
√ Node.js version
√ No .bowerrc file in home directory
√ No .yo-rc.json file in home directory
√ npm version
√ NODE_PATH matches the npm root
Everything looks all right!
Also I'm on Win10x64. Any ideas?
Fixed by #SBoudrias in version 0.15.1. Can you try npm uninstall -g yo && npm install -g yo ?

Unbale to run angular-material docs locally

I'm trying to run Angular-Material docs locally. I followed the instructions mentioned in the link
material/docs at master
Successfully executed npm install without errors (but with npm version warning - I'm just considering that thsi) after lots of googling and looking at SO answers.
When I execute bower install it throws the following error.
G:\Angular\material-master\docs\app>bower install
bower ENOENT No bower.json present
When I googled it I just got this link https://github.com/angular/material/issues/2407 saying
we no longer use bower within the /angular/material repository. Now you use only need to use npm.
And if I proceed to gulp docs I again get the error as below:
G:\Angular\material-master\docs\app>gulp docs
[19:37:47] Working directory changed to G:\Angular\material-master\docs
[19:37:48] Using gulpfile G:\Angular\material-master\docs\gulpfile.js
[19:37:48] Task 'docs' is not in your gulpfile
[19:37:48] Please check the documentation for proper gulpfile formatting
Where am I going wrong, how do I get it working? Any help is appreciated.
PS: I am not a pro at using node or at using angular. I also tried HTTPster method mentioned alternatively, but no luck.
G:\Angular\material-master\docs\app>httpster -p 8080 -d ./dist/docs
Starting HTTPster v1.0.1 on port "8080" from ./dist/docs
GET / 404 10ms
GET /index 404 2ms
GET /demo 404 2ms
GET /help 404 1ms
And also tried the same from root directory with a random hope, but just got same results.
My questions is not similar to
Not able to run angular material docs on locally which states a different error.
Looks like your installation is not complete. Please follow the steps.
Step 1: Get the Master Project by using git https://github.com/angular/material.git. OR Clone it locally.
Step 2: Run npm install.
Step 3: gulp build & gulp docs (install gulp first if you don't have).
Step 4: gulp server. (This start project at localhost:8080).
Sometimes it causing problem to run u can alternatively run it by going one step further.
Install http-server by using following command.
npm install http-server -g
then run using http-server dist/docs -p 8080 -a 127.0.0.1
Project available at http://localhost:8080/

Yeoman - Errors With Grunt Server Command

I already have npm and git installed on my Ubuntu machine.
I followed the instructions below when installing Yeoman and the generator-angular.
Kickstart Your AngularJS Development with Yeoman, Grunt and Bower (step by step tutorial)
http://www.sitepoint.com/kickstart-your-angularjs-development-with-yeoman-grunt-and-bower/
My ultimate goal is to lauch a simple app using twitter bootstrap, so I can take advantage of their pretty UI. :D
However, when I get to the portion to run grunt server (recently replaced by grunt serve), I get a rediculous number of errors:
I was previously suffering from the issue described below:
Cannot install yeoman because 'generator-karma does not satisfy its siblings peerDependencies
https://github.com/yeoman/yeoman/issues/1065
Luckily I was able to work around it by running npm uninstall -g generator-karma && npm install -g generator-angular and then sudo npm install -g yo grunt-cli bower.
However, now I've hit a wall with grunt appearing as if it's not installed at all.
Does anyone know if there is a specific location where grunt should be installed?
Should I install it globally (using -g)?
Should I not install it globally (using -g)?
I don't understand what I'm doing incorrectly, but it must be something fundamental because the process is intended to be automated and simple.
Any ideas?
This looks like something npm install would fix. Looks like some of your dependencies didn't install.
Try it first without -g.
The problem definitely has something to do with compass and ruby. I was able to quickly build an angular app using yeoman when I opted not to install compass/sass for the app when prompted after typing yo angular at the terminal. After following the suggestions in this post, the last error I got was the following error:
Warning: /home/ubuntu/.rvm/rubies/rubie-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_req‌​uire.rb:55:in 'require': cannot load such file -- compass (LoadError) from /home/ubuntu/.rvm/rubies/rubie-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_req‌​uire.rb:55:in 'require' from /usr/bin/compass:20:in 'block in ' from /usr/bin/compass:8:in 'fallback_load_path' from /usr/bin/compass:19:in '' Use --force to continue Although, --force doesn't help.
but fixed it by simply following these instructions.

What is causing 'grunt serve' to throw 'No Bower components found'?

I am starting out angular app with angular-fullstack in my Windows 7 box. I installed bunch of npm packages with -g options, including grunt-bower-install. I created the application first by running
yo angular-fullstack appname
There were no exception during the application creation. After application was created successfully I tried to run the app using
grunt serve
expecting the server to run. But the 'grunt serve' failed with
Running "bower-install:app" (bower-install) task
Cannot find where you keep your Bower packages.
We tried looking for a .bowerrc file, but couldn't find a custom
directory property defined. We then tried bower_components, but
it looks like that doesn't exist either. As a last resort, we tried
the pre-1.0 components directory, but that also couldn't be found.
Unfortunately, we can't proceed without knowing where the Bower
packages you have installed are.
Fatal error: No Bower components found.
I did find .bowerrc file and it was pointing to app/bower_components. Unfortunately, bower_components file was no where to be found. I am not sure what should be the content of the file to create it myself. Is it the missing file causing this problem or is there a npm package, I did not install correctly?
I installed bower using npm as well *
Thanks
Confusingly, the grunt-bower-install task that comes with angular-fullstack doesn't install bower components. It doesn't install anything. This error is trying to let you know that it can't find the bower_components directly, so it can't do its thing.
To fix the issue, run bower install.
If you don't have Bower installed, run npm install -g bower first.
I had the same issue, here's what worked in my case:
installed ruby and compass (yeoman needs these)
verified that path to Ruby bin folder is added to %PATH%
installed Git
restarted cmd window and ran "bower install" in the app folder
After that, grunt serve command worked perfectly.
Note: maybe installing Git and running bower install would suffice in your case.
I faced the same problem but only did npm install -g bower and then bower install and got grunt serve working.
I did not need to do any of the things mentioned by Olga.
Hope this helps.
npm install -g bower doesn't install bower components, you should run as well bower install to have all bower's components installed and then run grunt serve. It should work fine
Try to do bower install. If its failing saying not able to connect to git then you can change repo pointing location by simply running below command
$ git config --global url.https://github.com/.insteadOf git://github.com/
This will ensure that you will be downloaded over https instead of git if its causing orginasation firewall to block it.
In my case, I added sudo for it to work. So, I ran sudo npm install -g bowerand then bower install. grunt serve then worked when I ran it.
The Bower installation requires the packages to be brought from the Git repository, so first you need to install the Git application in your system. You can download it from this link :https://git-scm.com/downloads . Now after your have downloaded it , there may be a chance that the PATH may not be set up, so go to ControlPanel -> System and Security -> System -> Advance System Settings (on the left-hand side), click it, then goto Environment Variables -> System Variables -> PATH , click edit , and write down the following paths :
;C:\Users\admin\AppData\Local\Programs\Git\bin;
C:\Users\admin\AppData\Local\Programs\Git\cmd ....Well the above path is where Git was installed in my system, you can crawl to the place in your system where Git was installed and select the paths from the "bin" and "cmd" folder and paste it on the PATH variable.
Now, after the GIT path is setup, you can now type in the command " $ bower install " , this will install all of your bower packages.
npm install -g bower
bower install
grunt serve
worked for me ...
npm install -g bower
bower install
grunt serve
It's worked too

Resources