当我试图运行业力时,'未捕捉错误:找不到模块'柴''

时间:2017-11-06 06:27:15

标签: javascript node.js karma-runner

当我尝试运行Karma npm run karma start .\calculator.conf.js时,出现了错误:Uncaught Error: Cannot find module 'chai' at node_modules/_mocha@4.0.1@mocha/mocha.js:1,但是当我运行命令'npm run mocha'时,它没问题。

的package.json

```
"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "karma": "karma",
    "mocha": "mocha"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "chai": "^4.1.2",
    "karma": "^1.7.1",
    "karma-chai": "^0.1.0",
    "karma-chrome-launcher": "^2.2.0",
    "karma-mocha": "^1.3.0",
    "mocha": "^4.0.1"
  }
}
```

测试文件

```

    var chai = require('chai')
      , expect = chai.expect
      , should = chai.should();
    describe('accMul', function () {
      it('should return accurate number when all the parameter are integer', function () {
        expect(22).to.equal(22)
      })
    })

```

Karma配置文件:calculator.conf.js

```
config.set({
    frameworks: ['mocha'],
    files: [
      'src/*.js',
      'test/*.js'
    ],
    ...
)
```

我已尝试使用命令npm install chai -g,但它没有用,请帮忙!

0 个答案:

没有答案