[英]Karma cannot find module 'optimist'
I am trying to install angular phone cat app and run the test cases with karma test runner.我正在尝试安装 angular phone cat 应用程序并使用 karma test runner 运行测试用例。 I have node v0.10.33 installed.我安装了节点 v0.10.33。 and I have installed karma globally.我已经在全球范围内安装了 karma。 Now, i am trying to run the test cases with 'npm test' and I get following error:现在,我正在尝试使用“npm test”运行测试用例,但出现以下错误:
module.js:340
throw err;
^
Error: Cannot find module 'optimist'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\me\angular-phonecat\node_modules\karma\lib\cli.j
s:2:16)
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)
at Module.require (module.js:364:17)
Any idea ?任何的想法 ? I thought may be karma is not initialized right and I tried to run 'karma init' but same error again.我想可能是 karma 没有正确初始化,我尝试运行 'karma init' 但再次出现同样的错误。
Update-----更新 - - -
On running 'npm install' i get following errors:在运行“npm install”时,我收到以下错误:
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\karma requires s
ocket.io@'~0.9.13' but will load
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\socket.io,
npm WARN unmet dependency which is version 1.2.0
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\karma requires g
lob@'~3.2.7' but will load
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\glob,
npm WARN unmet dependency which is version 4.1.4
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\karma requires m
inimatch@'~0.2' but will load
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\minimatch,
npm WARN unmet dependency which is version 1.0.0
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\karma requires u
seragent@'~2.0.4' but will load
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\useragent,
npm WARN unmet dependency which is version 2.1.2
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\karma requires c
onnect@'~2.12.0' but will load
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\connect,
npm WARN unmet dependency which is version 3.3.3
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\bower\node_modul
es\handlebars requires optimist@'~0.3' but will load
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\optimist,
npm WARN unmet dependency which is version 0.6.1
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\bower\node_modul
es\bower-registry-client\node_modules\request\node_modules\form-data requires as
ync@'~0.9.0' but will load
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\bower\node_modul
es\bower-registry-client\node_modules\async,
npm WARN unmet dependency which is version 0.2.10
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\bower\node_modul
es\insight\node_modules\inquirer\node_modules\cli-color\node_modules\d requires
es5-ext@'~0.10.2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency C:\me\angular-phonecat\node_modules\bower\node_modul
es\insight\node_modules\inquirer\node_modules\cli-color\node_modules\timers-ext
requires es5-ext@'~0.10.2' but will load
Try do next steps before run npm install在运行 npm install 之前尝试执行后续步骤
node_modules
from your project从项目中删除文件夹node_modules
npm cache clean
运行npm cache clean
npm install
运行npm install
If you get Error: Cannot find module 'optimist' , try installing optimist .如果您收到错误:找不到模块 'optimist' ,请尝试安装optimist 。
To install optimist for any global use, try the following and reload shell要为任何全局使用安装 optimist,请尝试以下操作并重新加载 shell
sudo npm install -g --save optimist
Or for your case, please follow the below steps:或者对于您的情况,请按照以下步骤操作:
node_modules
from project从项目中删除目录node_modules
npm cache clean
运行npm cache clean
npm install
运行npm install
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.