Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get error with "line.slice()" on "karma init"

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.

like image 477
David M. Karr Avatar asked Sep 28 '13 19:09

David M. Karr


2 Answers

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.

like image 106
malkomich Avatar answered Oct 07 '22 02:10

malkomich


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

like image 24
Tharaka Avatar answered Oct 07 '22 01:10

Tharaka