why karma is not in the path after installing? - karma-runner

I would like to try using karma to run some javascript unit tests. However, after installing using npm install -g karma
I typed karma, the system prompt that karma cannot be found. Do I need to add karma to the path?

Yes. I'm guessing you're on Windows, which doesn't automatically put the folder containing your globally installed node_modules on your $PATH. You'll have to go into Windows' Advanced System settings and edit your path manually.

Related

ionic install fails on fsevents on Windows

I have tried to install ionic on Windows but installation has failed. What should I do?
I have tried more than 20 times but still I got the same problem.
Here I have attached the screenshot for this
Entered commands:
npm install -g cordova
npm install -g ionic
Note: this one windows server machine
My guess is that the NPM global path has not been added to your windows path.
These are the steps to try:
First verify that the command just installed can run. The output contains the full path to the command installed, just copy and paste it to the command line. In your case it might be something like this %APPDATA%\Roaming\npm\iconic -v
Lets assume that works. That means that the command was successfully installed and will run, now we need to add it to your PATH so you can run it from the command line.
Next, Press Windows key and type "path" and select "Edit environment variables for your account". From here. Add or append the path %APPDATA%\Roaming\npm to your PATH variable, and save the results.
Once it is on your PATH you can run it from any command shell window.
Next, start a new command shell (e.g., Windows+R, cmd, Enter) and then type the command iconic -v. Viola, it should work without requiring the full path to the script.
I'm doing most of this from memory so hopefully it's correct. But if it needs some tweeks, let me know and I'll update the answer.
For completness, this install didn't actually fail. The lines with fsevents are warnings. The fsevents package is only designed to work on Mac Unix so these warnings can be safely ignored.
As Suraj Rao mentioned, also see Nodejs cannot find installed module on Windows?.

Working on VS Code and after making a JS file I keep getting these two errors about TypeScript and jsHint

So I saved an external JS file for a project I was working on. And when I did that at the top of my editor I got this error:
2.[jshint] Failed to load jshint library. Please install jshint in your workspace folder using 'npm install jshint' or globally using 'npm install -g jshint' and then press Retry.
What exactly am I supposed to do to fix these errors? I've seen other people post this issue but I don't understand the solutions that people have been giving them. Can anyone walk me through fixing these two issues in plain, easy to understand English?
The first error means that vscode can not find an install of npm. We use npm to install files that power IntelliSense for external modules such as express.
To fix it:
Install node/npm if you have not already: https://nodejs.org/en/download/
Restart VS Code
If you still see this warning message after doing this, take a look at the docs on this. The workaround is to set "typescript.npm" to point to where npm is installed on your computer, for example:
"typescript.npm": "/Users/matb/.nvm/versions/node/v8.9.1/bin/npm"
The second error means that vscode cannot find a copy of the jshint library. As the error messages says, the fix is to use npm to install a copy of jshint in your workspace. From a commandline in your workspace, run:
npm install jshint
For all your workspaces (globally)
npm install -g jshint

WebStorm run npm script in tool window (Protractor)

I would like to be able to run an npm script in the Protractor tool window rather than npm. This is easily doable creating a new Protractor Run/Debug config but I need to add a command line argument which the Run config doesnt currently support.
More specifically I am trying to run
protractor --capabilities.chromeOptions.args=--headless --capabilities.chromeOptions.args=--disable-gpu
Would like to do this without modifying the protractor config file.
Essentially, I want to be able to do this without having to provide multiple config files in my project. One for headless, one without.
There is currently no way to specify cmd options in Protractor run configuration, please follow WEB-25165 for updates

Version mismatch between tsc compiler and VS Code's language service

I just started playing with Visual Studio Code and when I created a new file called index.html, I am shown this warning message
A version mismatch between the globally installed tsc compiler (1.0.3.0) and VS Code's language service (1.8.10) has
Can someone please guide me what i have to do to fix this.
Is this serious or I can ignore. I googled but could not get much info
Thanks
I added this to my settings.json file, accessed through preferences > Workspace Settings :
"typescript.tsdk": "node_modules/typescript/lib"
now I no longer receive this error and in the bottom right corner of my screen it shows the current version of Typescript that I have installed.
[UPDATE] VS Code 1.6 now ships with TypeScript 2.0.3.
I just installed the latest Typescript, currently v.2.0.3, and installed VS Code v.1.5.3 on macOS Sierra. For some reason, exactly following the official doc didn't work for me.
Here's how I made it work:
After having installed the latest version globally:
npm i -g typescript, I added the following line to my settings.json file (opened by cmd + ,):
"typescript.tsdk": "/usr/local/lib/node_modules/typescript/lib",
Hope this helps someone else.
[update] as #ptpaterson mentioned on the comment below, on Windows the path is: "typescript.tsdk": "C:/Users/{user_name}/AppData/Roaming/npm/node_modules/typescript/lib/"
You have to change the version of TypeScript that Visual Code is using to match the version you have installed:
https://code.visualstudio.com/docs/languages/typescript#_using-newer-typescript-versions
The above is taken from the link:
If you want to use a newer version of TypeScript, you can define the typescript.tsdk setting (File > Preferences > User/Workspace Settings) pointing to a directory containing the TypeScript tsserver.js file.
You can find the installation location using npm list typescript, tsserver.js is usually under the lib folder.
For example:
{
"typescript.tsdk": "node_modules/typescript/lib"
}
You have to update your Typescript installation and restart Code afterwards:
npm install -g typescript
or
npm install -g typescript#1.8.10
The message should not longer appear, if it worked.
This error was being generated because I had a reference to an older installation of TypeScript in my System Path variable:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\
The Visual Studio Code error was resolved when I removed this entry.
However, my TypeScript files then failed to transpile as the build action couldn't find the tsc.exe file.
When the SDK is installed (through Visual Studio or via a manual *.visx install), a tsc.exe file is installed and the PATH environment variable is updated to reference the folder that this file resides in (see above).
There is another way to transpile your files on a Windows environment by using node.js:
Install node.js. Installation packages can be found here.
Use npm to install TypeScript:
npm install -g typescript
This will add the TypeScript files to your profile AppData folder:
C:\Users\{your_user_name}\AppData\Roaming\npm\node_modules\typescript\lib
Configure your Visual Studio Code user settings.json file to reference this folder:
{
"typescript.tsdk": "C:\\Users\\{your_user_name}\\AppData\\Roaming\\npm\\node_modules\\typescript\\lib"
}
Add / update the user PATH environment variable to reference the folder that contains the tsc.cmd file:
%USERPROFILE%\AppData\Roaming\npm
None of the solutions above worked for me - first of all this is the global tsc I want to have updated to the latest version.
After I did some investigation it turned out that the problem lies in system's PATH variables; tsc.cmd (along with tscserver.cmd) exists in these locations:
c:\Program Files\nodejs - where the npm.exe and node.exe are
%USERPROFILE%\AppData\Roaming\npm - where global packages are
What you can do is to juggle environment\user variables so the tsc command would be resolved from %USERPROFILE% first instead of Program Files.
The quick & dirty way would be just deleting tsc.cmd and tscserver.cmd from the Program Files path.
Installing v2.0.3 of typescript was not sufficient... but but then updating the version dependency on package.json worked for me.
Npm command:
npm install -g typescript#2.0.3
Updated line on package.json:
"typescript": "^2.0.3"
The cause of my experience with this issue (in VSCode 1.8 on Mac OS X 10.12.2) was that I have been using NVM and while my code was running on the NVM version, VSCode was looking at a system installation of node.
Double check which installation of npm you are using to install typescript globally. If in doubt (on linux/mac) use which tsc from the command-line to verify the location being used by VSCode.
For example, if I simply call npm i -g typescript, npm resolves to ~/.nvm/versions/node/v6.9.1/bin/npm. I had to solve the problem by calling /usr/local/bin/npm i -g typescript explicitly because VSCode looks for node in /usr/local/bin/node by default.
Install TypeScript globally to share the installation across workspaces. In this case, you install it using npm install -g typescript#next.
You then have to tell VS Code on setting.json file (File -> Preferences -> Workspace Settings) the install location using the typescript.tsdk setting. Set typescript.tsdk to the path of the lib folder containing the tsserver.js file of the installed TypeScript module.
On windows:
"typescript.tsdk": "C:/Users/<MyUser>/AppData/Roaming/npm/node_modules/typescript/lib"
On Mac:
"typescript.tsdk": "/usr/local/lib/node_modules/typescript/lib"
Installing VSCode 1.6.0 fixed the TypeScript version mismatch warning message for me.
You'd think that this being a Microsoft product they'd give the Windows paths on their website
https://code.visualstudio.com/docs/languages/typescript#_using-newer-typescript-versions
but they don't. They only give the Unix path types.
Use:-
On windows: "typescript.tsdk": "C:/Users/YourNameHere/AppData/Roaming/npm/node_modules/typescript/lib/"
Note that forward strokes must be used even though Windows uses backstrokes for the paths!
Some other answers miss off the last forward stroke which is necessary.
You can just remove 'typescript.tsdk' and use the one embedded in Code if you don't really care about which tsdk version you use.

Chmod u+x windows cmd

I'm trying to install Scalatra on windows seven and need to change a file to executable...the Scalatra documentation says to do this, which is unix. What is the windows equivalant?
chmod u+x srt
You can simply open the relevant folder with a unix command prompt (I use git bash) and execute the unix commands from there
To get scalatra-sbt going on Windows, either port you own sbt.bat from scalatra-sbt, or install chmod via cygwin.
Assuming you've successfully installed the rest of Conscript and giter8, you can start a project that downloads scalatra-sbt. From there, one can look through the ./sbt source, and port the bash script functionality to your own windows specific script, or install a unix compatibility layer into Windows. If you go down the "windows specific script" route, perhaps the scalatra-sbt would appreciate the project contribution.
The "unix compatibility layer" route will eventually allow you to run ./sbt. chmod is a unix command line function, and is provided in a default package of the tool set cygwin, which provides a complete lunix-like environment. Once inside a cygwin terminal, you can chmod your file, as mentioned in the scalatra-sbt first project.
Diving into the contents of ./sbt from scalatra-sbt, this is actually unix script wrapper around the scala build tool (also referred to, confusingly, as sbt). If while trying to run ./sbt you get strange '\r' errors, install the cygwin package dos2unix, and then run it on the sbt file. If you run into any "which: no curl in..." or "which: no wget in..." errors, go back to the cygwin installer, find those packages such as wget, and then install those programs.
By the way, the last thing the scalatra-sbt script runs is the Scala build tool. The Scala build tool sbt itself has many reported issues with cygwin's default configuration, so you will likely need to do more research. Depending on what issues you're running into on your specific setup, you may need to make changes to the end of the ./sbt script to adjust the parameters used to launch the Scala build tool.