摩卡&运行npm install时的chai依赖项

时间:2015-12-29 00:56:04

标签: npm ionic-framework mocha bower chai

我想用Grunt(Yeoman Ionic)运行Ionic应用程序 为此,脚本将运行npm installbower install。然后运行grunt进行编译,然后运行grunt serve以在本地主机上提供服务。

npm install不会与Mocha和Chai创建对等依赖关系,这会导致bower install中止,如下所示:

Running "karma:continuous" (karma) task
Warning: Cannot find module 'mocha' Use --force to continue.

Aborted due to warnings.

我跑npm install -g chai mocha然后npm install并获得相同的

 npm WARN karma-mocha@0.1.10 requires a peer of mocha@* but none was installed.
npm WARN karma-chai@0.1.0 requires a peer of chai@* but none was installed.

即使这是一个警告,它在运行yo ionic时会产生错误:

npm WARN karma-chai@0.1.0 requires a peer of chai@* but none was installed.
npm WARN karma-mocha@0.1.10 requires a peer of mocha@* but none was installed.
ERROR: Error: ENOENT: no such file or directory, rename '/Users/donjohnson/ionicNom/app/app/css' -> '/Users/donjohnson/ionicNom/app/app/styles'
ERROR: Error: ENOENT: no such file or directory, rename '/Users/donjohnson/ionicNom/app/app/js' -> '/Users/donjohnson/ionicNom/app/app/scripts'
ERROR: Error: ENOENT: no such file or directory, rename '/Users/donjohnson/ionicNom/app/app/img' -> '/Users/donjohnson/ionicNom/app/app/images'

这使得grunt服务打开一个没有任何内容的浏览器页面:(

2 个答案:

答案 0 :(得分:12)

package { import flash.display.MovieClip; import Main; public class MyClass extends MovieClip { public var m:Main; public function MyClass() { m = new Main(); m.myFunc(); } } } 到您的项目(没有npm install --save-dev mocha chai)。

从版本3开始,npm不会自动安装peerDependencies

答案 1 :(得分:1)

似乎在NPM 3中,默认情况下不会安装依赖项,请使用此更新:

npm install chai@*
npm install mocha@*

然后使用:

npm install
bower install