7

I was started to read "Developing an AngularJS Edge", and I wanted to set up the various frameworks in use.

The book uses nodejs and karma, along with several other frameworks.

I'm on Win7x32.

I just upgraded my nodejs to the latest, v0.10.18 .

I installed the Karma package with "npm install -g karma". This appeared to complete successfully.

I then ran "karma init", which did this:

    % karma init
> 
readline.js:507
  this.line = this.line.slice(this.cursor);
                        ^
TypeError: Cannot call method 'slice' of undefined
    at Interface._deleteLineLeft (readline.js:507:25)
    at suggestNextOption (C:\Users\David\AppData\Roaming\npm\node_modules\karma\lib\init.js:167:9)
    at nextQuestion (C:\Users\David\AppData\Roaming\npm\node_modules\karma\lib\init.js:235:12)
    at process (C:\Users\David\AppData\Roaming\npm\node_modules\karma\lib\init.js:250:10)
    at Object.exports.init (C:\Users\David\AppData\Roaming\npm\node_modules\karma\lib\init.js:352:6)
    at Object.<anonymous> (C:\Users\David\AppData\Roaming\npm\node_modules\karma\bin\karma:25:37)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

Note that this error is virtually identical to the stack trace reported by this person a month ago, but that report has received no response.

Community
  • 1
  • 1
David M. Karr
  • 14,317
  • 20
  • 94
  • 199

8 Answers8

7

Probably you're using the Git Bash terminal, MinTTY, which doesn't have full support for TTY.

You have 4 options to fix the problem:

  1. Use CMD terminal with the Windows shell (the default Windows console)
  2. Use CMD terminal with the Bash shell (execute "C:\Program Files\Git\bin\bash.exe" --login -i in cmd terminal)
  3. Use Powershell (an alternative terminal typically installed by default in Windows environments)
  4. Use an alternative terminal (or develop a new one :stuck_out_tongue_winking_eye: )

If you just need execute isolated interactive commands like karma init, I recommend option 1 for it and then come back to Git Bash. However I would give a try to Powershell.

malkomich
  • 311
  • 4
  • 13
2

The reason for the error with running npm in Cygwin seems to be a known issue with npm. You can use the work around mentioned here,

https://stackoverflow.com/a/22436199/2390020

Community
  • 1
  • 1
Tharaka
  • 2,355
  • 1
  • 20
  • 22
2

Faced the same issue.try this

node node_modules/karma/bin/karma init

Raphael
  • 1,738
  • 2
  • 27
  • 47
1

I got the same error with MINGW64.

Runs properly on default command prompt.

Krunal Shah
  • 653
  • 2
  • 10
  • 16
0

One other likely relevant point that I failed to mention is that I was running these commands from a Cygwin rxvt window.

I just tried completely uninstalling nodejs and reinstalling it.

When I brought up the rxvt window again and ran "npm install -g karma", it failed with the following:

/c/Program Files/nodejs/npm: line 2: $'\r': command not found
/c/Program Files/nodejs/npm: line 4: $'\r': command not found
/c/Program Files/nodejs/npm: line 5: syntax error near unexpected token `$'in\r''
'c/Program Files/nodejs/npm: line 5: `case `uname` in

That led me to search for that error on the web, and I found this thread, which implies that it simply doesn't support Cygwin (unfortunate, but not a huge problem).

When I then brought up a plain, ugly, unfriendly "cmd" window, both the karma installation and "karma init" completed successfully (or at least it gave me the first question in the "init" process).

David M. Karr
  • 14,317
  • 20
  • 94
  • 199
0

In my case, the problem was that I was using the git bash terminal in windows. When I ran the command in a cmd window it worked fine.

Eric
  • 1
  • 1
0

Run the command in github shell command window. Worked for me.

Kshri
  • 414
  • 3
  • 16
0

If you open up the karma file it's just a node script, so an alternative way of executing it would be:

node karma init

This worked for me in the MINGW64/git bash shell

codebox
  • 19,927
  • 9
  • 63
  • 81