How to set the environment variable CHROME_BIN when working in an IDE? - angularjs

I'm trying to follow the AngularJS tutorial: https://docs.angularjs.org/tutorial. I use the IDE Cloud9.
When I enter npm test it returns No binary for Chrome browser on your platform. Please, set "CHROME_BIN" env variable. And the same message for FIREFOX_BIN.
How am I supposed to set these environment variables?
I've tried the following:
In the command prompt of Windows (on my pc, not in cloud9) I entered SET CHROME_BIN = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" but this didn't make a difference.
I also tried it when changing karma.conf.js to:
browsers : ['C:/Program Files (x86)/Google/Chrome/Application/chrome.exe', 'C:/Program Files (x86)/Mozilla Firefox/firefox.exe'],
but then I got the error Can not load "Script", it is not registered! Perhaps you are missing some plugin? so that doesn't seem to be the right way to go either.
If in Cloud9 I enter env SET CHROME_BIN = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" it returns env: SET: No such file or directory.

I also ran into the same problem using the Cloud9 IDE.
While, I didn't solve the Chrome problem, I went with PhantomJS, which worked with Cloud9.
To install on the command line:
npm install karma-phantomjs-launcher --save-dev
In the karma.conf.js file:
// start these browsers
browsers: ['PhantomJS'],

Add variable for the current user using powershell:
[Environment]::SetEnvironmentVariable("CHROME_BIN",'...', "User")
This is not exactly the same as what you want as variable will not be temporary but the effect will be the same.
Your own command will work if you execute it in the same shell as npm:
PS> $Env:CHROME_BIN = '...'
PS> npm test
...
I am using here Powershell syntax exclusively.
I am not familiar with Cloud9 but generally, to set variable up for the IDE you would need to run it from the script that sets the variable prior to launching the IDE (the same as I showed you with nmp above).

Related

Installing Protractor for Angular JS in VScode

I have npm installed globally and installed protractor globally as well. When I check for the node version it returns proper version, but when I am trying to check the version of protractor after installing it gives me the below error. can anyone help me with whats going wrong here?
protractor : The term 'protractor' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
+ protractor --version
You need to config the global protractor into PATH environment variable through
below two steps:
get npm global package install path by execute following cmd which will print out an absolute folder path.
npm config get prefix
add the install path/bin into PATH environment variable
For example the step 1 print out xxx\yyy, you should add xxx\yyy\bin; into PATH on Windows, Or add xxx\yyy\bin: on Linux.
Important: try protrator --version in new cmd window, Don't try again in previous opened cmd window.

Is this possible to install node-sass offline proxy

I'm trying to install node-sass module using npm but each time an error displayed about a problem in network configuration that's because i'm using proxy and private registry this is the error :
This is most likely not a problem with node-gyp or the package itself and is related to network connectivity In most cases you are behind a proxy or have bad network setting
Is it possible to install this module offline ?
I had a similar problem, while trying to install node-sass behind a corporate proxy.
What you can try is:
Download it locally from here:https://github.com/sass/node-sass/releases (choose the right one depending on your OS)
Use the binary configuration parameter –sass-binary-path. to install it.
npm install --sass-binary-path="C:\src\v4.7.2\win32-x64-57_binding.node"
How-to
Download the binary here: https://github.com/sass/node-sass/releases
It vary depending on your OS and node version.
Set up env variable (see https://github.com/sass/node-sass#binary-configuration-parameters)
export SASS_BINARY_PATH=<absolute_path_to_file>
Replace <absolute_path_to_file> by the path to the file you have downloaded. The path should be absolute, and in linux format (if you use git bash, with cmd use Windows format). To get the absolute path, you can go to the directory, open a git bash console and do pwd, append the filename, and you should have something like /c/Users/you/SOFTWARE/win32-x64-64_binding.node.
Install (locally)
npm i node-sass --save
You need to export the variable once for each opened terminal using node-sass. Meaning you should add the export line to your npm start. (so you gotta keep the file you downloaded somewhere safe).
For example you can do "start:dev": "set SASS_BINARY_PATH=%cd%\\win32-x64-64_binding.node && npm start". In this case, the sass binary is inside my project, making it easier for new collaborators. We are using set instead of export because Jetbrain IDE use by default cmd (Windows terminal).
Miscellaneous
If you get an error message like:
Testing binary
Binary has a problem: Error: The module '\\?\C:\Users\myself\SOFTWARE\win32-x64-72_binding.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
It means it have found your binary, but you took the wrong one for your current node version. Dowload the correct version, and do theses above step again.
when using npm start if you have (used on a react-script project):
./src/product-card-list/product-card-list.component.module.scss (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-6-1!./node_modules/postcss-loader/src??postcss!./node_modules/sass-loader/lib/loader.js??ref--6-oneOf-6-3!./src/product-card-list/product-card-list.component.module.scss)
Error: ENOENT: no such file or directory, scandir 'C:\Users\myself\PROJECTS\advisor_spa\node_modules\node-sass\vendor'
You failed step 4. Export SASS_BINARY_PATH again and it should work.
If you use Webstorm, you can make run configuration for npm start and add full path SASS_BINARY_PATH=C:\Users\myself\SOFTWARE\win32-x64-64_binding.node environment variable (for Windows).
If you use Visual Code on Windows, you can add a system env variable, at the same level as PATH (not inside PATH).

Nagios Plugin Error: (No output on stdout) ... failed. errno is 2: No such file or directory

I am using custom Nagios plugins for the first time and am running into this error when I create a service for the plugin.
(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/check_load.py, ...) failed. errno is 2: No such file or directory
The plugin works when I run it on the command line, however does not work when it runs within Nagios.
I followed these steps to get the plugin into Nagios
https://assets.nagios.com/downloads/nagiosxi/docs/Managing-Plugins-in-Nagios-XI.pdf
Here is what it looks like in the Nagios UI
The plugin is in the correct path: /usr/local/nagios/libexec and the resource.cfg file has the same path within it.
I tried two separate plugins, both which work on the command line, and the result is the same error.
The error indicates the file location is incorrect, however the plugin is in the specified directory and runs with no errors within that directory.
I am totally stumped and appreciate any help.
For anyone reading this, I solved the problem.
The first time I added the plugin, I forgot to add the python extension. When I updated the already created plugin, Nagios still threw the error.
Once I completely deleted the plugin and re-created it the 'file not found', error went away.
I faced a similar issue when I was trying to add a custom plugin ( I had custom plugins in ruby and python ).
The issue was the missing shebang line at the start of the script (which determines the script's ability to be executed like a standalone executable).
For example, if you have a python plugin custom-plugin.py then make sure this script has shebang at the start of script #!/usr/bin/env python3. Also if you have other scripts (ruby, bash etc.) make sure to add the appropriate path at the start of your scripts.
Also, check the path for plugins Nagios version. For my setup path was /usr/local/nagios/libexec/ and make sure your custom plugin is executable and has correct ownership permissions.
Sample custom template I used :
define command {
command_name check_switch_health
command_line /usr/local/nagios/libexec/check_snmp.rb --host $HOSTADDRESS$ --model "$ARG1$" --community "$ARG2$"
}
The above workaround worked for me.

How to setup the proxy info in yypkg for sherpa.exe when installing Win-builds Project

I am trying to install the latest GCC compiler on windows 7 by using "Win-builds Project". Since the company I am working for has proxy. When I run the command win-install.bat. I got an error:
http://win-builds.org/1.3.0/packages/windows_64/package_list.el:
2014-02-21 11:39:44 ERROR 407: Proxy Authentication Required.
In the batch file, I found code:
yypkg -init
yypkg -config -setpreds host=%_YY_ARCH%-w64-mingw32
yypkg -config -setpreds target=%_YY_ARCH%-w64-mingw32
sherpa -set-mirror http://win-builds.org/1.3.0/packages/windows_%_YY_BITS%
I think the yypkg.exe does the initialization work and configs sherpa and let sherpa.exe to download and install files.
My question is how can config yypkg my username and password? I did google search, but I cannot find any info about yypkg nor how to config sherpa.
[enter code here][1]Proxy set up can be done via command line
How can I set a proxy server for gem?
set http_proxy=http://your_proxy:your_port
set http_proxy=http://username:password#your_proxy:your_port
set https_proxy=https://your_proxy:your_port
set https_proxy=https://username:password#your_proxy:your_port
These command snippets need to be entered on 'cmd.exe', and before running the wget, to download files manually via portable wget as described on page:
http://win-builds.org/doku.php/download_and_installation_from_windows
few IMPORTANT Pointers, after the packages have been downloaded manually, and running the 'yypkg-1.5.0.exe'
At first the Application UI is unresponsive, DO NOT CLOSE IT
After some time, change mirror dialog appears where you would need to type/paste the Local folders location(this is the folder where files were downloaded manually)
Local folder path needs to be similar to the following where 'package_list.el.tar.xz' file resides.
file:///C:/usr/MinGW/1.5.0/packages/windows_64
after that all works fine

Using PhantomJS with Karma (Win7 x64)

Does anyone have a simple getting started guide on how to configure Karma to use PhantomJS?
Using the phonecat sample, I have Karma running with Chrome fine and although the Karma docs mention PhantomJS (which I now have installed) I can't figure out how to amend the config file to get it to run.
I've tried putting PhantomJS in the the browsers array of testacular.conf.js but I get;
{ [Error: spawn OK] code: 'OK', errno: 'OK', syscall: 'spawn' }
Which I think means it's launching OK but it appears to me that (as a PhantomJS noob) it requires a different command line. I've also downloaded phantomjs-launcher but it's not obvious how to use that.
(I'm running Windows 7 64-Bit if that makes a difference.)
test.bat
#echo off
REM Windows script for running unit tests
REM You have to run server and capture some browser first
REM
REM Requirements:
REM -NodeJS (http://nodejs.org/)
REM -Testacular (npm install -g karma)
set BASE_DIR= % ~dp0
karma start "%BASE_DIR%\..\config\testacular.conf.js" %*
testacular.conf.js
basePath = '../';
files =[
JASMINE,
JASMINE_ADAPTER,
'app/lib/angular/angular.js',
'app/lib/angular/angular-*.js',
'test/lib/angular/angular-mocks.js',
'app/js/**/*.js',
'test/unit/**/*.js'
];
autoWatch = true;
browsers =['Chrome', 'phantomjs'];
junitReporter = {
outputFile: 'test_out/unit.xml',
suite: 'unit'
};
According to procmon.exe PhantomJS wasn't launching at all, so to circumvent environmental issues, I've since amended my config thus;
browsers = ['Chrome','%USERPROFILE%\\AppData\\Roaming\\npm\\phantomjs.cmd'];
where %userprofile% is expanded, which seems to launch it, but now I get this;
INFO [launcher]: Starting browser %USERPROFILE%\AppData\Roaming\npm\phantomjs.cmd
ERROR [launcher]: Cannot start %USERPROFILE%\AppData\Roaming\npm\phantomjs.cmd
Can't open 'http://localhost:9876/?id=16572367'
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn OK
at errnoException (child_process.js:975:11)
at Process.ChildProcess._handle.onexit (child_process.js:766:34)
That error seems to be coming from PhantomJS.exe now.
First, install PhantomJS using npm:
npm install -g phantomjs
You may then need to specify the location of the PhantomJS executable for karma. The npm install will tell you where it put the executable. For me, running karma in Git Bash, I added the following to ~/.profile:
export PHANTOMJS_BIN ='C:/Users/JohnSmith/AppData/Roaming/npm/node_modules/phantomjs/lib/phantom/phantomjs.exe'`
Those two steps, plus adding PhantomJS to the browsers entry, were sufficient to get karma to successfully invoke Phantom and run all of my tests.
Use PhantomJS launcher and set env PHANTOMJS_BIN to the correct location of your phantomjs binary. That is phantomjs.exe on windows, not the .cmd file (the cmd file is just a npm wrapper on windows).
In your code, you are using a script browser launcher (a custom shell script to launch a browser). That is possible, but the script has to accept a single argument which is the url that it should open. PhantomJS does not behave like that.
I was seeing this error when using a relative path in node's child_process.spawn() function --
var spawn = require('child_process').spawn;
var child = spawn('phantomjs', ['./suspendmonitors.js']);
The solution for me was to use the absolute path:
var spawn = require('child_process').spawn;
var child = spawn('phantomjs', ['C:/Users/kkhalsa/workspace/misc_scripts/phantomjs/suspendmonitors.js']);
For some reason, the relative path worked when calling the node script from a windows command prompt, but didn't when invoking the node script in Windows powershell.
Are you using cmd.exe or Powershell?
Try manually adding the PHANTOMJS_BIN and point it to the phantomjs.exe, not the .cmd.

Resources