Reputation: 4628
For some reason Circle is not able to use ts-mocha
installed with npm install
in a previos step in the building process.
It used to work, but for some reason it doesn't anymore out of a sudden.
This is the CircleCI build job result:
All tests are running fine locally:
This is the script in the package.json
that I run with npm test
:
"test": "env NODE_ENV=test ts-mocha ./test/**/*.spec.ts --timeout 10000"
The package version is "ts-mocha": "^6.0.0",
This is my CircleCI job configuration (which hasn't changed in a month):
jobs:
build:
docker:
- image: circleci/node:10.13.0
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package-lock.json" }}
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package-lock.json" }}
- run: npm test
- run: npx tsc
It seems that something broke from the Circle side, as there were no changes in the code.
Even though I tried rerunning old successful builds, they fail with this same error.
Things I tried:
npm ci && npm test
in the same step but it yields the same result.package-lock.json
package-lock.json
npm install --no-package-lock
npm update
npm audit fix
Also tried using npx
instead of relying on the previously installed ts-mocha
package and this is the result:
Upvotes: 2
Views: 1585
Reputation: 4628
I noticed that the CircleCI NODE_ENV
environment variable was set to production
, therefore any devDependencies
were not getting installed (even with npm install --save
, because it was already listed as a devDependency
in the package.json
).
I don't know when the environment variable was changed to that value, but the odd thing is that it started breaking from one day to another (although it should've been breaking since the moment that env variable was set) so it was extremely hard to debug, but it was a simple fix: changing the NODE_ENV
environment variable in CircleCI to something different than production
.
Upvotes: 1