gpt4 book ai didi

node.js - Karma-jasmine 未安装

转载 作者:搜寻专家 更新时间:2023-10-31 22:59:11 24 4
gpt4 key购买 nike

我是单元测试的新手,所以我今天才知道JasmineKarma

我安装了 Karma:

npm init
npm install karma --save-dev
npm install -g karma-cli
npm install karma-jasmine --save-dev
npm install karma-chrome-launcher --save-dev
karma init

但是,当我尝试启动 karma start karma.conf.js 时,它抛出了一个错误:

Error: Cannot find module 'jasmine-core'
at Function.Module._resolveFilename (module.js:338:15)
at Function.require.resolve (module.js:389:19)
at initJasmine (/Users/appfoundry/Projects/Unit Testing/node_modules/karma-jasmine/lib/index.js:8:42)
at Array.invoke (/Users/appfoundry/Projects/Unit Testing/node_modules/di/lib/injector.js:75:15)
at get (/Users/appfoundry/Projects/Unit Testing/node_modules/di/lib/injector.js:48:43)
at /Users/appfoundry/Projects/Unit Testing/node_modules/karma/lib/server.js:137:20
at Array.forEach (native)
at Server._start (/Users/appfoundry/Projects/Unit Testing/node_modules/karma/lib/server.js:136:21)
at invoke (/Users/appfoundry/Projects/Unit Testing/node_modules/di/lib/injector.js:75:15)
at Server.start (/Users/appfoundry/Projects/Unit Testing/node_modules/karma/lib/server.js:101:18)
at Object.exports.run (/Users/appfoundry/Projects/Unit Testing/node_modules/karma/lib/cli.js:231:26)
at requireCliAndRun (/usr/local/lib/node_modules/karma-cli/bin/karma:44:16)
at /usr/local/lib/node_modules/karma-cli/bin/karma:54:12
at /usr/local/lib/node_modules/karma-cli/node_modules/resolve/lib/async.js:44:21
at ondir (/usr/local/lib/node_modules/karma-cli/node_modules/resolve/lib/async.js:187:31)
at /usr/local/lib/node_modules/karma-cli/node_modules/resolve/lib/async.js:153:39

我尝试在全局安装核心:

npm install -g jasmine-core

但这并没有解决问题。

当我尝试安装 npm install karma-jasmine 时,我收到一条错误消息:

 karma-jasmine@0.3.6 requires a peer of jasmine-core@* but none was installed.

最佳答案

https://github.com/karma-runner/karma-jasmine

Note: Since karma-jasmine 0.3.0 the jasmine library is no longer bundled with karma-jasmine and you have to install it on your own. You can simply do it by:

npm install jasmine-core --save-dev

$ npm install jasmine-core --save-dev
$ npm install karma-jasmine --save-dev

关于node.js - Karma-jasmine 未安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34263840/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com