chaijs 模块找不到问题
 发布于 10 年前  作者 xxlv  3793 次预览  最后一次回复是 10 年前  来自 问答 

大家好,我使用

node install -g chai

安装了chai ,我使用

npm -g list |grep chai

可以看到chai@3.0.0,接下来我在我的test.js中使用,

var chai=require(‘chai’); var expect=require(‘chai’).expect; describe(‘services’,function(){

describe(’#demo’,function(){ it(‘services should return a string’,function(done){ expect(‘hello’).to.a(‘string’); done(); }); }); });

结果我得到了一个错误,

Cannot find module ‘chai’

这是怎么回事呢?

2 回复
William17

不能在项目中直接加载全局的第三方模块.建议装在项目中,无须依赖全局环境.

npm install chai --save-dev
joesonw

-g安装一般是安装全局的binary