Npm run test command doesn't work

Keywords: MEAN - AWS - Technical issue - Other
Description:
Hi everybody,

I’d like run Nodejs test using mocha, but, as I run the following command

npm run test

I get the following error:
bitnami@ip-172-31-64-14:/opt/microservices/authenticator$ npm run test

api-backend@0.0.1 test /opt/microservices/authenticator
nyc --reporter=text-summary ./node_modules/mocha/bin/mocha ./dist/test/test.js

internal/modules/cjs/loader.js:969
throw err;
^

Error: Cannot find module ‘…/lib/config-util’
Require stack:

  • /opt/microservices/authenticator/node_modules/.bin/nyc
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object. (/opt/microservices/authenticator/node_modules/.bin/nyc:4:20)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions…js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
    code: ‘MODULE_NOT_FOUND’,
    requireStack: [ ‘/opt/microservices/authenticator/node_modules/.bin/nyc’ ]
    }
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! comply-api-backend@0.0.1 test: nyc --reporter=text-summary ./node_modules/mocha/bin/mocha ./dist/test/test.js
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the comply-api-backend@0.0.1 test script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/bitnami/.npm/_logs/2021-04-12T13_25_36_676Z-debug.log

If I run directly the following command

nyc --reporter=text-summary ./node_modules/mocha/bin/mocha ./dist/test/test.js

my tests work!

It seems I have come issues with NPM.

Can I solve this issue?

Many thanks for your support.
Simone

Hello @simone.tiso,

The error seems to be coming from a misconfiguration as you checked the test are working properly and the log says:

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Unfortunately, we do not have expertise in this area and this is something that goes beyond our knowledge. Checking StackOverflow a bit, I have found several cases similar to yours. You can start checking the following threads, I hope they are of help!

Regards,
Francisco de Paz

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.