Installing Protractor for Angular JS in VScode - angularjs

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.

Related

Expo CLI not recognised

im trying to create a new react-native app and to create it i need the expo CLI so i installed it via npm but then after trying to run expo init.... an error response occrured as the following:
expo : The term 'expo' 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
expo init _______
+ CategoryInfo : ObjectNotFound: (expo:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Would apperciate any help, Thanks.
If you could share additional screenshots that would be helpful.
One thing that is super easy to overlook is the path.
For example, you create a new folder "myApp"
Inside that folder you run npm install/expo init/etc.
What this does is creates another folder inside that one.
So your new path should be C://path/myApp/myApp
If you edit your question with screen shots/more info, then I can give a more detailed answer.
I had this issue before and here are some things to try:
install expo-cli globally (you dont explicitly state you've done this) npm i -g expo-cli
If you are using PowerShell and you are getting messages along the line of expo.ps1 cannot load because the execution of scripts is disabled on this system. you need to enable script execution. Decide on the script execution scope you want. Choices are Restricted (the current setting if you are getting this message), AllSigned, Unrestricted, and RemoteSigned (probably the one you want). Then open PowerShell as an admin and run
Set-ExecutionPolicy RemoteSign
Make sure npm is added to path (on Windows look for %USERPROFILE%\appData\Roaming\npm)
The classic uninstall, reboot, and reinstall

unable to set npm terminal into VS code / windows

I want to install react, so I searched and I see I must download npm first
so I went to download npm, and I saw I must download node and set it in VS code terminal
I download nodejs.zip and but it in this path C:\node\node.exe
after this I went to cmd and wrote node -v, replied:
'node' is not recognized as an internal or external command,
operable program or batch file.
then I went to the control panel and wrote the path to the system vars
the same thing happens
I searched in StackOverflow and I found I most write SET PATH=C:\node\node.exe;%PATH% in cmd
it worked but not for a while, after restarting the PC the error still in my face
then I added node path to settings.json file like this
"terminal.integrated.profiles.windows": {
.
.
.
"Node Js": {
"path": "C:\\node\\node.exe"
}
},
and make it default
"terminal.integrated.defaultProfile.windows": "Node Js",
and finally, now I can run node in VS code "good rhythm"
but...
when I write node -v in node terminal replies :
Uncaught ReferenceError: node is not defined
and when npm init react-app myApp:
npm should be run outside of the Node.js REPL, in your normal shell.
(Press Ctrl+D to exit.)
and on npx create-react-app hi :
npx create-react-app hi
^ ^ ^ ^ ^ ^ //pointing on create
Uncaught SyntaxError: Unexpected identifier
I only want to run this npm init react-app myApp or npm init react-app myApp command
IDC for node or anything else
I try downloading node.msi (setup file) from this link
When you do SET PATH, it sets the variable for the session, but if you want it to be permanent, put the path into the global PATH variable. See this link on how to do it. In short, setting the variable in the command prompt lets you use the variable in the current command prompt session, and gets unset (or in this case, set back to the default) when you close the command prompt. Windows has a handful of environment variables that you can set which will be loaded automatically when you launch the command prompt, which Path is one of them. Alternatively, you can also do what you said and use the .msi file which does the job for you.

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).

'ng' is not recognized as an internal or external command, operable program or batch file. (Mean Stack)

Hello am currently writing a meanstack application, each time i run ng new client, it keeps reporting 'ng' is not recognized as an internal or external command,
operable program or batch file. Any idea what's the problem thanks.Note i already ran npm install #angular/cli so i just need to run ng new client to get on my way.I am running the command on the node.js command prompt.
Hello aready found an answer to my question, instead of running npm install #angular/cli just use npm install -g #angular/cli. Note the difference is that you need to install angular cli globally. thanks and hope anybody with same error finds luck.
If you are using Windows you can solve this problem editing the ".npmrc" adding this value: prefix=${APPDATA}\npm.
You can to find this file in "c:\Users\YOURUSERHERE". To view this file you need to display the hidden items.
After doing this, simply install the Angular and be happy.

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

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).

Resources