web-ext icon indicating copy to clipboard operation
web-ext copied to clipboard

Investigate "nyc"-related failure while running test-coverage npm script on travis windows workers

Open rpl opened this issue 6 years ago • 1 comments

In some recent Pull Requests, the travis CI job running on windows is failing with the following error message:

Running mocha unit tests...
----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |        0 |        0 |        0 |        0 |                   |
----------|----------|----------|----------|----------|-------------------|
The command "npm run test-coverage" exited with 1.
internal/modules/cjs/loader.js:638
    throw err;
    ^
Error: Cannot find module 'C:\Users\travis\build\mozilla\web-ext\node'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

After some tests to be able to bisect what combination of node, npm and nyc is able to trigger the issue, I've been able to reproduce the same failure locally consistently and it looks related to something going wrong between nyc and the particular npm version being used (sigh :°-| ).

To identify the npm version that starts to trigger this issue I've executed the following command on windows 10 and git bash on multiple npm versions:

$ export NPMV=NN.N.N; rm -rf node_modules/; npx npm@$NPMV ci && npx npm@$NPMV run test-coverage

with the following results:

- [email protected] => OK
- [email protected] => OK
- [email protected] => OK
- [email protected] => OK
- [email protected] => BROKEN but different error
- [email protected] => BROKEN
- [email protected] => BROKEN

On [email protected] the error is:

> [email protected] test-coverage D:\MOZLAB\web-ext
> nyc npm run test

'find_dp0' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:573
    throw err;
    ^

Error: Cannot find module 'D:\nyc\bin\nyc.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:571:15)
    at Function.Module._load (internal/modules/cjs/loader.js:497:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:719:10)
    at startup (internal/bootstrap/node.js:228:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:575:3)

It also worth to notice that the issue looks to be actually introduced in the "npm ci" step, because running a version that wasn't affected based on the test described above on the node_modules/ directory created with an affected version leads to the same error.

rpl avatar Oct 25 '19 17:10 rpl

#1738 and #1731 are two of the pull requests that are currently blocked by this issue.

rpl avatar Oct 25 '19 17:10 rpl