li x li x - 1 year ago 211
Node.js Question

Travis CI NodeJs build runs locally but gets a permission denied on Travis CI

So when I run locally the mocha test inside my repo It works just fine but when I push a commit and it runs on travis CI I keep getting this error:

sh: 1: mocha: Permission denied

npm ERR! Test failed. See above for more details.

my .travis.yml

language: node_js
- "6"

-npm install

before_script: npm install -g mocha
before_script: chmod 0777 ./node_modules/.bin/mocha


"name": "skeletonapp",
"version": "0.0.0",
"description": "skeletonapp",
"main": "index.js",
"author": {
"name": "li"
"scripts": {
"test": "mocha"
"dependencies": {
"chai": "^3.5.0",
"mocha": "^3.1.2"

structure of files


var assert = require('assert');
describe('Array', function () {
describe('#indexOf()', function () {
it('should return -1 when the value is not present', function () {
assert.equal(-1, [1, 2, 3].indexOf(4));

Answer Source

Turn on the execute permission on node_modules/.bin:

Or, remove node_modules from your Git repository, and let Travis install it with npm install. (See

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download