Mocha command is not found after adding in environment Variables in CodeBuild

In my buildspec.yml file I have a post-build command that runs my mocha tests:

npm run mochatest

That is something I have set in package.json as follows:

"scripts": {
  "mochatest": "mocha --timeout 30000 test/functional_api_crud.js"
},

CodeBuild runs and it starts mocha and then I had a test failure because an environment variable I used in my Node.js code was not set. So, I went into the advanced settings of CodeBuild and added in the needed environment variables. Now when the run happens I get an error that mocha cannot be found! The error lines are:

[Container] 2017/12/28 19:24:29 Running command npm run mochatest
[email protected] mochatest /codebuild/output/src251232826/src
mocha --timeout 30000 test/functional_api_crud.js
sh: 1: mocha: not found
npm ERR! Please include the following file with any support request:
npm ERR! /codebuild/output/src251232826/src/npm-debug.log

This started happening after I added in my own environment variables! Did some other environment variable get upset because I did this?


It turns out that I had set the NODE_ENV environment variable to production and thus, an npm install does not bring in my devDependencies modules!