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










share|improve this question







New contributor




lafal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    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










    share|improve this question







    New contributor




    lafal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      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










      share|improve this question







      New contributor




      lafal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      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






      share|improve this question







      New contributor




      lafal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      lafal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      lafal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Nov 5 at 2:17









      lafal

      1




      1




      New contributor




      lafal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      lafal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      lafal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          lafal is a new contributor. Be nice, and check out our Code of Conduct.










           

          draft saved


          draft discarded


















          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





































          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.










           

          draft saved


          draft discarded


















          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.















           


          draft saved


          draft discarded














          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




















































































          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()