Travis build failing due to mocha not found in project subfolder
up vote
0
down vote
favorite
I have the following compilation error using Travis CI for my github project:
sh: 1: mocha: not found
My main project folder, "projectRoot", which corresponds to my github repo, contains the .travis.yml configuration file; it also contains several sub folders (one per application):
projectRoot
|-- app1
|-- app1.js
|-- package.json
|--- node_modules
|--- .bin
|--- mocha
|--- mocha.cmd
|-- app2
|-- app2.js
|-- package.json
|--- node_modules
|--- .bin
|--- mocha
|--- mocha.cmd
|-- app3
|-- ...
Each application has its own package.json and node_modules packages.
The package.json of app1 contains the following:
"scripts": {
"test": "mocha"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^5.2.0"
},
And I get the following error when Travis CI tries to run the unit tests of app1:
$ npm test
> projectRoot@1.0.2 test /home/travis/build/username/projectRoot/app1
> mocha
sh: 1: mocha: not found
npm ERR! Test failed. See above for more details.
I tried adding the following before_script to change the current directory to app1, then amending the PATH variable prior to starting the tests:
before_script:
- echo "*** PRE BUILD SCRIPT ***"
- cd ./app1
- export PATH=$(pwd)/node_modules/.bin:$PATH
- echo $PATH
- echo "*************************"
After doing so, the "echo $PATH" line above shows in the travis logs that PATH contains the project folder:
$ echo $PATH
/home/travis/build/username/projectRoot/app1/node_modules/.bin:/home/travis/.rvm/gems/ruby-2.4.1/bin:/home/travis/......
But the error remains.
I also tried:
PATH=./node_modules/.bin:$PATH.
or changing the test script to use a relative path:
"scripts": {
"test": "./node_modules/.bin/mocha"
}
But the same error remains.
Any advise would be truly appreciated.
Many thanks for your help
javascript node.js mocha travis-ci
New contributor
add a comment |
up vote
0
down vote
favorite
I have the following compilation error using Travis CI for my github project:
sh: 1: mocha: not found
My main project folder, "projectRoot", which corresponds to my github repo, contains the .travis.yml configuration file; it also contains several sub folders (one per application):
projectRoot
|-- app1
|-- app1.js
|-- package.json
|--- node_modules
|--- .bin
|--- mocha
|--- mocha.cmd
|-- app2
|-- app2.js
|-- package.json
|--- node_modules
|--- .bin
|--- mocha
|--- mocha.cmd
|-- app3
|-- ...
Each application has its own package.json and node_modules packages.
The package.json of app1 contains the following:
"scripts": {
"test": "mocha"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^5.2.0"
},
And I get the following error when Travis CI tries to run the unit tests of app1:
$ npm test
> projectRoot@1.0.2 test /home/travis/build/username/projectRoot/app1
> mocha
sh: 1: mocha: not found
npm ERR! Test failed. See above for more details.
I tried adding the following before_script to change the current directory to app1, then amending the PATH variable prior to starting the tests:
before_script:
- echo "*** PRE BUILD SCRIPT ***"
- cd ./app1
- export PATH=$(pwd)/node_modules/.bin:$PATH
- echo $PATH
- echo "*************************"
After doing so, the "echo $PATH" line above shows in the travis logs that PATH contains the project folder:
$ echo $PATH
/home/travis/build/username/projectRoot/app1/node_modules/.bin:/home/travis/.rvm/gems/ruby-2.4.1/bin:/home/travis/......
But the error remains.
I also tried:
PATH=./node_modules/.bin:$PATH.
or changing the test script to use a relative path:
"scripts": {
"test": "./node_modules/.bin/mocha"
}
But the same error remains.
Any advise would be truly appreciated.
Many thanks for your help
javascript node.js mocha travis-ci
New contributor
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have the following compilation error using Travis CI for my github project:
sh: 1: mocha: not found
My main project folder, "projectRoot", which corresponds to my github repo, contains the .travis.yml configuration file; it also contains several sub folders (one per application):
projectRoot
|-- app1
|-- app1.js
|-- package.json
|--- node_modules
|--- .bin
|--- mocha
|--- mocha.cmd
|-- app2
|-- app2.js
|-- package.json
|--- node_modules
|--- .bin
|--- mocha
|--- mocha.cmd
|-- app3
|-- ...
Each application has its own package.json and node_modules packages.
The package.json of app1 contains the following:
"scripts": {
"test": "mocha"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^5.2.0"
},
And I get the following error when Travis CI tries to run the unit tests of app1:
$ npm test
> projectRoot@1.0.2 test /home/travis/build/username/projectRoot/app1
> mocha
sh: 1: mocha: not found
npm ERR! Test failed. See above for more details.
I tried adding the following before_script to change the current directory to app1, then amending the PATH variable prior to starting the tests:
before_script:
- echo "*** PRE BUILD SCRIPT ***"
- cd ./app1
- export PATH=$(pwd)/node_modules/.bin:$PATH
- echo $PATH
- echo "*************************"
After doing so, the "echo $PATH" line above shows in the travis logs that PATH contains the project folder:
$ echo $PATH
/home/travis/build/username/projectRoot/app1/node_modules/.bin:/home/travis/.rvm/gems/ruby-2.4.1/bin:/home/travis/......
But the error remains.
I also tried:
PATH=./node_modules/.bin:$PATH.
or changing the test script to use a relative path:
"scripts": {
"test": "./node_modules/.bin/mocha"
}
But the same error remains.
Any advise would be truly appreciated.
Many thanks for your help
javascript node.js mocha travis-ci
New contributor
I have the following compilation error using Travis CI for my github project:
sh: 1: mocha: not found
My main project folder, "projectRoot", which corresponds to my github repo, contains the .travis.yml configuration file; it also contains several sub folders (one per application):
projectRoot
|-- app1
|-- app1.js
|-- package.json
|--- node_modules
|--- .bin
|--- mocha
|--- mocha.cmd
|-- app2
|-- app2.js
|-- package.json
|--- node_modules
|--- .bin
|--- mocha
|--- mocha.cmd
|-- app3
|-- ...
Each application has its own package.json and node_modules packages.
The package.json of app1 contains the following:
"scripts": {
"test": "mocha"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^5.2.0"
},
And I get the following error when Travis CI tries to run the unit tests of app1:
$ npm test
> projectRoot@1.0.2 test /home/travis/build/username/projectRoot/app1
> mocha
sh: 1: mocha: not found
npm ERR! Test failed. See above for more details.
I tried adding the following before_script to change the current directory to app1, then amending the PATH variable prior to starting the tests:
before_script:
- echo "*** PRE BUILD SCRIPT ***"
- cd ./app1
- export PATH=$(pwd)/node_modules/.bin:$PATH
- echo $PATH
- echo "*************************"
After doing so, the "echo $PATH" line above shows in the travis logs that PATH contains the project folder:
$ echo $PATH
/home/travis/build/username/projectRoot/app1/node_modules/.bin:/home/travis/.rvm/gems/ruby-2.4.1/bin:/home/travis/......
But the error remains.
I also tried:
PATH=./node_modules/.bin:$PATH.
or changing the test script to use a relative path:
"scripts": {
"test": "./node_modules/.bin/mocha"
}
But the same error remains.
Any advise would be truly appreciated.
Many thanks for your help
javascript node.js mocha travis-ci
javascript node.js mocha travis-ci
New contributor
New contributor
New contributor
asked Nov 5 at 2:17
lafal
1
1
New contributor
New contributor
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
lafal is a new contributor. Be nice, and check out our Code of Conduct.
lafal is a new contributor. Be nice, and check out our Code of Conduct.
lafal is a new contributor. Be nice, and check out our Code of Conduct.
lafal is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147477%2ftravis-build-failing-due-to-mocha-not-found-in-project-subfolder%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password