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

I started reading "AngularJS Edge Development" and I wanted to customize the various frameworks used.

The book uses nodes and karma, as well as several other frameworks.

I am on Win7x32.

I just updated my nodes to the latest, v0.10.18.

I installed the Karma package with "npm install -g karma". It has been successful.

Then I 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) 

Please note that this error is almost identical to the stack trace reported by this person a month ago, but this report did not receive a response.

+7
javascript karma-runner
source share
6 answers

The cause of the error when starting npm in Cygwin seems to be a known problem with npm. You can use the work described here,

stack overflow

+2
source share

Perhaps you are using a Git Bash terminal, MinTTY, which does not have full TTY support.

You have 4 options to fix the problem:

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

If you just need to execute isolated interactive commands, for example karma init , I recommend option 1 for it, and then return to Git Bash. However, I would try Powershell.

+6
source share

I got the same error with MINGW64.

Works correctly on the default command line.

+1
source share

Another probable problem that I didn’t mention is that I ran these commands from the Cygwin rxvt window.

I just tried to completely remove nodejs and reinstall it.

When I ran 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 

This led me to search for this error on the Internet, and I found this thread , which means that it just does not support Cygwin (unsuccessful, but not a huge problem).

When I raised the simple, ugly, unfriendly cmd window, both karma setup and init karma completed successfully (or at least that gave me the first question in the init process).

0
source share

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

0
source share

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

0
source share

All Articles