加载“ grunt-karma.js”任务...错误>>语法错误:意外的标识符

时间:2019-08-17 13:25:42

标签: javascript angularjs gruntjs karma-jasmine

加载“ grunt-karma.js”任务时出错。所有其他任务加载正常。 更新了许多依赖项(包括grunt-karma和karma)后,开始发现问题。

来自我的package.json:

“ grunt-karma”:“ ^ 3.0.2”, “ karma”:“ ^ 4.2.0”,

我在Gruntfile.js中的Karma配置:

/**
 * The Karma configurations.
 */
karma: {
    options: {
        configFile: '<%= build_dir %>/karma-unit.js'
    },
    unit: {
        port: 9019,
        background: true
    },
    continuous: {
        singleRun: true
    }
},

当我运行grunt watch --verbose --debug时,这是我看到的错误:

Registering "grunt-karma" local Npm module tasks.
Reading C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\grunt-karma\package.json...OK
Parsing C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\grunt-karma\package.json...OK
Loading "grunt-karma.js" tasks...ERROR
>> C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\karma\lib\server.js:117
>>   async start () {
>>         ^^^^^
>> SyntaxError: Unexpected identifier
>>   at createScript (vm.js:56:10)
>>   at Object.runInThisContext (vm.js:97:10)
>>   at Module._compile (module.js:542:28)
>>   at Object.Module._extensions..js (module.js:579:10)
>>   at Module.load (C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\coffeescript\lib\coffee-script\register.js:45:36)
>>   at tryModuleLoad (module.js:446:12)
>>   at Function.Module._load (module.js:438:3)
>>   at Module.require (module.js:497:17)
>>   at require (internal/module.js:20:19)
>>   at Object.<anonymous> (C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\karma\lib\index.js:4:16)
>>   at Module._compile (module.js:570:32)
>>   at Object.Module._extensions..js (module.js:579:10)
>>   at Module.load (C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\coffeescript\lib\coffee-script\register.js:45:36)
>>   at tryModuleLoad (module.js:446:12)
>>   at Function.Module._load (module.js:438:3)
>>   at Module.require (module.js:497:17)
>>   at require (internal/module.js:20:19)
>>   at Object.<anonymous> (C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\grunt-karma\tasks\grunt-karma.js:9:30)
>>   at Module._compile (module.js:570:32)
>>   at Object.Module._extensions..js (module.js:579:10)
>>   at Module.load (C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\coffeescript\lib\coffee-script\register.js:45:36)
>>   at tryModuleLoad (module.js:446:12)
>>   at Function.Module._load (module.js:438:3)
>>   at Module.require (module.js:497:17)
>>   at require (internal/module.js:20:19)
>>   at loadTask (C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\grunt\lib\grunt\task.js:313:10)
>>   at C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\grunt\lib\grunt\task.js:351:7
>>   at Array.forEach (native)
>>   at loadTasks (C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\grunt\lib\grunt\task.js:350:11)
>>   at Task.task.loadNpmTasks (C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\grunt\lib\grunt\task.js:398:5)
>>   at Object.module.exports (C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\Gruntfile.js:17:11)
>>   at loadTask (C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\grunt\lib\grunt\task.js:315:10)
>>   at Task.task.init (C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\grunt\lib\grunt\task.js:434:5)
>>   at Object.grunt.tasks (C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\grunt\lib\grunt.js:111:8)
>>   at Object.module.exports [as cli] (C:\Development\gitrepository\ContactCenterRepos\ccs-sdk\CCS_SDK\JavaScript\RefClient\node_modules\grunt\lib\grunt\cli.js:27:9)
>>   at Object.<anonymous> (C:\Users\pruane\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt:44:20)
>>   at Module._compile (module.js:570:32)
>>   at Object.Module._extensions..js (module.js:579:10)
>>   at Module.load (module.js:487:32)
>>   at tryModuleLoad (module.js:446:12)
>>   at Function.Module._load (module.js:438:3)
>>   at Module.runMain (module.js:604:10)
>>   at run (bootstrap_node.js:389:7)
>>   at startup (bootstrap_node.js:149:9)
>>   at bootstrap_node.js:504:3

1 个答案:

答案 0 :(得分:0)

我将业力版本恢复为3.1.4,不再看到该问题:

"karma": "^3.1.4",

还尝试了Karma 4.0.0版,但仍然存在错误。