3
votes

I'm trying to use Travis CI to run my mocha + chai tests for the first time and I cant seem to figure out why this is happening.

When the Travis build runs:

mocha

sh: 1: mocha: not found

The command "npm test" exited with 1.

.travis.yml

language: node_js

node_js:
- "8"

package.json (not the whole thing)

"scripts": {
    "test": "mocha"
},
"Dependencies": {
    "mocha": "3.4.2",
    "chai": "4.0.2"
},

I also tried the test being: "test": "./node_modules/.bin/mocha" but that didn't work either.

Thanks for your help!

EDIT:

I'm not the smartest.... had Dependencies instead of dependencies (left over from when it said devDependencies!)


1
Hey, don't put yourself down, it's a simple typo that could happen to any of us :-) Good work for spotting it and answering your own question.ocean
Did you try add npm install -g mocha on .travis.yml config file ?King Jk

1 Answers

1
votes

The way I solved this is that I went to the menu button of travis, then I went to cache, and I cleared it... when you cleared the cache on travis, it tries to download it, then it fails, then does npm install to install all the dependancies again.