Karma: Cannot read property 'slice' of undefined

Created on 25 Nov 2015  路  21Comments  路  Source: karma-runner/karma

OliverSalzburg@Oliver-PC MINGW64 ~/Projects/absync (dev)
$ karma init karma.conf.js
> readline.js:525
  this.line = this.line.slice(this.cursor);
                       ^

TypeError: Cannot read property 'slice' of undefined
    at Interface._deleteLineLeft (readline.js:525:24)
    at suggestNextOption (C:\Users\Oliver\Projects\absync\node_modules\karma\lib\init\state_machine.js:43:9)
    at nextQuestion (C:\Users\Oliver\Projects\absync\node_modules\karma\lib\init\state_machine.js:119:12)
    at process (C:\Users\Oliver\Projects\absync\node_modules\karma\lib\init\state_machine.js:135:10)
    at Object.exports.init (C:\Users\Oliver\Projects\absync\node_modules\karma\lib\init.js:247:6)
    at Object.exports.run (C:\Users\Oliver\Projects\absync\node_modules\karma\lib\cli.js:237:25)
    at requireCliAndRun (C:\Users\Oliver\AppData\Roaming\npm\node_modules\karma-cli\bin\karma:44:16)
    at C:\Users\Oliver\AppData\Roaming\npm\node_modules\karma-cli\bin\karma:54:12
    at C:\Users\Oliver\AppData\Roaming\npm\node_modules\karma-cli\node_modules\resolve\lib\async.js:44:21
    at ondir (C:\Users\Oliver\AppData\Roaming\npm\node_modules\karma-cli\node_modules\resolve\lib\async.js:187:31)
    at C:\Users\Oliver\AppData\Roaming\npm\node_modules\karma-cli\node_modules\resolve\lib\async.js:153:39
    at onex (C:\Users\Oliver\AppData\Roaming\npm\node_modules\karma-cli\node_modules\resolve\lib\async.js:93:22)
    at C:\Users\Oliver\AppData\Roaming\npm\node_modules\karma-cli\node_modules\resolve\lib\async.js:24:18
    at FSReqWrap.oncomplete (fs.js:82:15)

I just installed karma and tried to init a new configuration. Seems to be a problem with MINGW. The command works in the default Command Prompt.

bug-upstream windows

Most helpful comment

Workaround that works nicely in GIT BASH shell is to call it directly using node

node node_modules/karma/bin/karma init

All 21 comments

I got the same error with MINGW64.

Runs properly on default command prompt.

@krunalsha You're correct. Thanks.

same here on git-bash (which I think is just MINGW64)

same error occurs on msys2

I am getting the same error on git-bash. Like the OP said, it works in Windows Command Prompt. The weird thing is I've been using karma for 6 months and had no problems with it until today. If I remember what I did to cause myself grief I'll post up here.

What version of node are you using?

Also what version of karma?

Oliver@oliver-home MINGW64 /f/temp/kt
$ karma init karma.conf.js
> readline.js:525
  this.line = this.line.slice(this.cursor);
                       ^

TypeError: Cannot read property 'slice' of undefined
    at Interface._deleteLineLeft (readline.js:525:24)
    at suggestNextOption (C:\Users\Oliver\AppData\Roaming\npm\node_modules\karma\lib\init\state_machine.js:43:9)
    at nextQuestion (C:\Users\Oliver\AppData\Roaming\npm\node_modules\karma\lib\init\state_machine.js:119:12)
    at process (C:\Users\Oliver\AppData\Roaming\npm\node_modules\karma\lib\init\state_machine.js:135:10)
    at Object.exports.init (C:\Users\Oliver\AppData\Roaming\npm\node_modules\karma\lib\init.js:247:6)
    at Object.exports.run (C:\Users\Oliver\AppData\Roaming\npm\node_modules\karma\lib\cli.js:241:25)
    at Object.<anonymous> (C:\Users\Oliver\AppData\Roaming\npm\node_modules\karma\bin\karma:3:23)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:134:18)
    at node.js:961:3

Oliver@oliver-home MINGW64 /f/temp/kt
$ karma --version
Karma version: 0.13.19

Oliver@oliver-home MINGW64 /f/temp/kt
$ node --version
v4.2.1

Upgraded to Node 4.3.0. Problem persists

I am using the same version of Karma (0.13.19), karma-cli 0.1.2, and node 4.2.2.

same error by ref: http://stackoverflow.com/questions/19070777/get-error-with-line-slice-on-karma-init

my karma version 0.13.21
my nodejs version: v4.3.1

same error

cygwin shell: CYGWIN_NT-6.1 localhost 2.5.1(0.297/5/3) 2016-04-21 22:14 x86_64 Cygwin
Karma version: 0.13.22
Node version: v4.4.4

I could ran this command (karma init) in windows using windows command line instead of MINGW.

have same issue in git-bash, use windows command line to solve it.

not solved yet:l same error

Hi, I was able to reproduce this by creating ~/Desktop/Dockerfile:

FROM node

RUN mkdir -p /app/code

RUN cd /app && npm i --save-dev karma karma-chrome-launcher karma-mocha karma-chai
RUN cd /app && npm i --save-dev mocha chai

WORKDIR /app

RUN node --version
RUN ./node_modules/karma/bin/karma --version
RUN ./node_modules/karma/bin/karma init karma.conf.js

Then running:

cd ~/Desktop && docker build .

Karma version: 1.7.1
Node version: v9.1.0

Same result with with node:7

Same issue for me in Powershell ISE.
OS: Win 10
Node: 8.9.4
Karma: 2.0.0

However it does function properly in CMD. Just a note for future viewers of this thread.

Workaround that works nicely in GIT BASH shell is to call it directly using node

node node_modules/karma/bin/karma init

@godzillalad Thank you!It works!

@godzillalad so,the reason is because karma's path recognition is invalid under windows?

Was this page helpful?
0 / 5 - 0 ratings