Yeoman: EACCES error running karma unit test for Angularjs - yeoman

I'm following the sample Yeoman workflow listed on yeoman.io:
npm install -g generator-angular generator-karma # install generators
yo angular # scaffold out a AngularJS project
bower install angular-ui # install a dependency for your project from Bower
*grunt test # test your app
grunt server # preview your app
grunt # build the application for deployment
Everything works great except the grunt test command:
C:\yeoman2>grunt test
(logging omitted for brevity)
Running "connect:test" (connect) task
Starting connect web server on localhost:9000.
Running "karma:unit" (karma) task
Fatal error: listen EACCES
I haven't updated my gruntfile or made any other modifications to the configs. Has anyone seen this EACCESS error before? I'm on Windows 8, with a fresh node install.

This was happening because the karma server was running on port 8080. I changed it (in karma.conf.js) to 9999 and all is well.

Related

Rails 7.0 application with bootstrap on development mode

I have created a new rails app, after that I have installed bootstrap with cssbundling-rails,
I am now getting an error The asset "application.css" is not present in the asset pipeline. In order to have the application run I need to run the following script
"scripts": { "build:css": "sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules" },
Only after that there is an application file created on assets/builds path.
But I don't want to run this command every time I am updating the css files, I want the server to pick those updates without running the yarn script.
How can I achieve that?
I recently ran into an issue similar to this and the source of the problem was in fact npm and yarn.
A properly configured application using cssbundling-rails should not need to run the command
"scripts": { "build:css": "sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules" },
to get the application to generate the build/application.css
npm known issue
Check your npm version, there is an issue if you are not using npm 7.1+ that basically prevents yarn from setting things up correctly.
Run npm -v and if necessary, upgrade npm with npm install -g npm#latest
If you had to upgrade npm, you will then need to close out your terminal and launch a new one, verify that the npm version is greater than 7.1.
After upgrading, re run rails css:install:bootstrap
And everything should be configured correctly.
Bundle Watcher
From the documentation for cssbundling-rails
"You develop using this approach by running the bundler in watch mode in a terminal with yarn build:css --watch (and your Rails server in another, if you're not using something like puma-dev). You can also use ./bin/dev, which will start both the Rails server and the CSS build watcher (along with a JS build watcher, if you're also using jsbundling-rails)."
So, you can either run yarn build:css --watch from a separate terminal in your rails application or just use the ./bin/dev but either way should resolve the issue you are experience.

Npm install of aurelia project in docker container gets stuck/hangs on jenkins build server

Problem
Most of my Jenkins builds get stuck at npm install. The issue is not reproducible locally what makes it hard to narrow down. The build server would just endlessly hang at a "random" package while until you'd manually stop it.
16:33:55 [0m[91mnpm http fetch GET 200 https://registry.npmjs.org/ws/-/ws-6.2.1.tgz 737ms
Analysis
The frontend is developed with Aurelia and is part of a monorepo that is managed by Docker. This is my only project that uses Aurelia CLI so I thought I could find the problem there - but without any results.
I've already tried to analyze the issue by executing npm install --verbose but didn't gain any additional valuable information. It wasn't a specific package that lead to the problem nor was it a noticeable timeout.
# Dockerfile
FROM node:12.13.0 as builder
WORKDIR /web
COPY web .
RUN pwd
RUN npm install --verbose
RUN npm run build
FROM nginx:mainline-alpine
COPY --from=builder /web/dist /usr/share/nginx/html
COPY html/index.html /usr/share/nginx/html/index2.html
COPY nginx.conf /etc/nginx/nginx.conf
After investigating the problem for a long time, I discovered the newly introduced npm ci command and used it instead of npm install which solved the problem. Unfortunately installing a project with a clean state is a good idea ;-)
This command is similar to npm-install, except it’s meant to be used
in automated environments such as test platforms, continuous
integration, and deployment – or any situation where you want to make
sure you’re doing a clean install of your dependencies. It can be
significantly faster than a regular npm install by skipping certain
user-oriented features. It is also more strict than a regular install,
which can help catch errors or inconsistencies caused by the
incrementally-installed local environments of most npm users.

Not able to run angular material docs on locally

Environment: Windows 7, npm 2.11.3, bower 1.4.1, gulp CLI 3.9.0
I Cloned angular material (https://github.com/angular/material/tree/v0.10.1) using WebStorm. I followed the (https://github.com/angular/material/tree/v0.10.1/docs) to install angular-material locally.
At root directory /
I run npm install it runs (with some warnings) and downloaded its dependencies (my npm -v is 2.11.3)
In run bower install but its gives following
D:\material>bower install
bower ENOENT No bower.json present
then I run gulp docs to build docs, it was build and created /dist folder at root directory. after I run the gulp server command to live reload. Its said Webserver started at http://0.0.0.0:8080 I saw on bower but no luck, also tried alternativly as http://localhost:8080 still there is no luck.
One more alternative using httpster, I installed it and run httpster -p 8080 -d ./dist/docs it said Starting HTTPster v1.0.1 on port "8080" from ./dist/docs
again i browse localhost:8080 then its gives me error in index page on developer tool of crome as below
Uncaught Error: [$injector:nomod] http://errors.angularjs.org/1.4.3/$injector/nomod?p0=material.components.menu
angular.js:4369 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.3/$injector/modulerr?p0=docsApp&p1=Error%3A…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.3%2Fangular.min.js%3A19%3A339)
Please help what can I do to get my luck.
Paul (ngmaterial group on google) solved my problem, However site is loading demo pages not working.
Try renaming _menu.js in material-0.10.1\src\components\menu to menu-a.js. In my case that ensured the two js files were added in the correct order.

Can't run webpack in rails project

I'm trying to run the rails application https://github.com/lumenlearning/OpenAssessments on a linux server. I've been able to get most aspects of it working, but I can't get webpack to run correctly. The project readme states to run the following commands:
$ npm install -g webpack
$ cd client && webpack
Webpack installs correctly, but when I run it as stated, I just get the webpack usage help. I assume this is because there is no webpack.config.js file in the client directory. There is, however, one in client/config: https://github.com/lumenlearning/OpenAssessments/blob/master/client/config/webpack.config.js
If I run webpack in client/config, then webpack is able to find the config file, but I get the following error:
Config did not export an object.
Should I be running webpack in a different way? I am very new to webpack.
Thanks!

Deploying a Rails / Ember app on AWS Elastic Beanstalk

I am having issues deploying my elastic beanstalk rails 4 + ember cli app. I have a rails application and within the root I have a folder called 'frontend' which contains my ember app generated by ember CLI Rails.
My configuration:
64bit Amazon Linux 2015.03 v1.3.1 running Ruby 2.1 (Puma)
I encounter the following error from my activity log after I run eb deploy:
At cursory, I get this
ERROR: Instance: i-25c139e7 Module: AWSEBAutoScalingGroup ConfigSet: null Command failed on instance. Return code: 1 Output: (TRUNCATED)...mber-cli-rails.rb:58:in `compile!'
Looking into /var/log/eb-activity.log
I first get a lot of
npm ERR! Error: Attempt to unlock X, which hasn't been locked
followed by
npm ERR! System Linux 3.14.35-28.38.amzn1.x86_64
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /var/app/ondeck/frontend
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /var/app/ondeck/frontend/npm-debug.log
npm ERR! not ok code 0
rake aborted!
EmberCLI Rails requires your Ember app to have an addon.
From within your EmberCLI directory please run:
$ npm install --save-dev ember-cli-rails-addon#0.0.11
in you Ember application root: /var/app/ondeck/frontend
Tasks: TOP => assets:precompile => ember:compile
(See full trace by running task with --trace) (Executor::NonZeroExitStatus)
So I ssh into the directory indicated and run npm install, which also leaves me with a lot of errors regarding authorization. When I run with via sudo, the modules install correctly, but when I redeploy my app, it gives me the exact same error.
I have tried sudo NPM install and chown -R node_modules webapp so that the node_modules folder can be accessed by the webapp group with no success.
I hate long answers, but this scenario is quite complicated.
As mentioned in the comments above, it was discovered that the home directory for the webapp user needed to be created (/home/webapp). Once this directory is created, the node package manager (npm) can execute without error. Because AWSEB environments can scale, SSH'ing into the EB host and performing one-off installations of packages and modules will not work in the long run. Essentially the answer boils down to the following logical steps:
Install git on the application server because bower needs it.
Create the home directory of the webapp user at /home/webapp.
Install bower globally using npm.
Invoke the npm install of your ember app.
Invoke bower install for your ember app.
To fix this I went ahead and created several .ebextensions customization files that are executed during an eb deploy. Here they are in order:
.ebextensions/00_option_settings.config - sets some EB options; for example the timeout length for command executions performed during an eb deploy. In this case all commands will timeout after 1200 seconds.
option_settings:
- namespace: 'aws:elasticbeanstalk:command'
option_name: 'Timeout'
value: '1200'
.ebextensions/01_packages.config - can install packages through yum and make them available to your eb instance. In this case I use yum to install git, this will later be used by bower.
packages:
yum:
git: []
.ebextensions/02_commands.config - allows you to run OS commands prior to unpacking the application that was uploaded through eb deploy. This part of the answer satisfies the main theme of this question: In my particular case, I need to create the /home/webapp directory, make sure it is owned by the webapp user, and also has 700 permissions. Lastly, I ensure that bower is installed globally as it will be needed by my ember application.
commands:
01_mkdir_webapp_dir:
# use the test directive to create the directory
# if the mkdir command fails the rest of this directive is ignored
test: 'mkdir /home/webapp'
command: 'ls -la /home/webapp'
02_chown_webapp_dir:
command: 'chown webapp:webapp /home/webapp'
03_chmod_webapp_dir:
command: 'chmod 700 /home/webapp'
04_install_bower_global:
command: 'npm install -g bower'
.ebextensions/03_container_commands.config - runs OS command after the application has been unpacked. NOTE: My ember app lives in the frontend directory of application source code. In order to install the npm and bower dependencies, the npm install and bower install commands need to be executed from the frontend directory. It is also worth mentioning that the bower-install command needs the --allow-root flag in order to succeed as the AWS user executing these commands has elevated privileges.
container_commands:
01_npm_install:
# set the current working directory to fully-qualified frontend
cwd: '/var/app/ondeck/frontend/'
command: 'npm install'
leader_only: 'false'
02_bower_install:
# set the current working directory to fully-qualified frontend
cwd: '/var/app/ondeck/frontend/'
command: 'bower --allow-root install'
leader_only: 'false'
03_seeddb:
# seed my database (has nothing to do with this answer)
command: 'rake db:seed_fu'
leader_only: 'true'

Resources