Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test-with-coverage is broken on node v16 #1130

Closed
nfischer opened this issue Aug 28, 2023 · 1 comment · Fixed by #1139
Closed

test-with-coverage is broken on node v16 #1130

nfischer opened this issue Aug 28, 2023 · 1 comment · Fixed by #1139

Comments

@nfischer
Copy link
Member

Node version (or tell us if you're using electron or some other framework):

v16, v18, or v20

ShellJS version (the most recent version/Github branch you see the bug on):

main git branch

Operating system:

All

Description of the bug:

It looks like CI is broken right now. It appears that nyc is running into a bug on node v16, v18, and v20. See this CI run for an example: https://github.com/shelljs/shelljs/actions/runs/5956710281/job/16287478757?pr=1129. Here's the main stack that I see:

/home/runner/work/shelljs/shelljs/node_modules/append-transform/index.js:1
TypeError [ERR_INVALID_ARG_TYPE]: The "mod" argument must be an instance of Module. Received an instance of Module
    at new NodeError (node:internal/errors:387:5)
    at makeRequireFunction (node:internal/modules/cjs/helpers:74:11)
    at Module._compile (node:internal/modules/cjs/loader:1188:19)
    at Module.replacementCompile (/home/runner/work/shelljs/shelljs/node_modules/append-transform/index.js:58:[13](https://github.com/shelljs/shelljs/actions/runs/5956710281/job/16287478757?pr=1129#step:5:14))
    at Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at /home/runner/work/shelljs/shelljs/node_modules/append-transform/index.js:62:4
    at Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at /home/runner/work/shelljs/shelljs/node_modules/append-transform/index.js:62:4 {
  code: 'ERR_INVALID_ARG_TYPE'

This appears to have regressed recently, so maybe this is a change in the latest node LTS versions.

Example ShellJS command to reproduce the error:

N/A. This reproduces with npm run test-with-coverage.

nfischer added a commit that referenced this issue Aug 28, 2023
For some reason it seems like `nyc` v14 is incompatible with node
v16/v18/v20. See this CI run as an example:
https://github.com/shelljs/shelljs/actions/runs/5956710281/job/16287478757?pr=1129

This updates `nyc` to v15 which should fix the issue.

Fixes #1130
Test: nvm use v16.20.2
Test: npm run test-with-coverage
@nfischer
Copy link
Member Author

I confirmed this does not repro with 16.0.0, however the bug does repro with 16.20.2. So I guess this really is a regression in the latest node LTS. I think node is now handle JS modules more strictly.

So far the only workarounds I've identified are:

  • Downgrade to node 16.0.0, or
  • Upgrade nyc to version 15.1.0 (which only supports nodejs >= 8.9, whereas version 14 currently supports node v6).

nfischer added a commit that referenced this issue Nov 11, 2023
No change to logic. This updates nyc (code coverage tool) to version 15.
The main goal is to work around a bug on the latest nodejs LTS versions.

This change indicates it only supports nodejs >= 8.9. Hopefully this is
good enough for our purposes since ShellJS currently supports
nodejs >= 8.

Fixes #1130
nfischer added a commit that referenced this issue Nov 12, 2023
No change to logic. This updates nyc (code coverage tool) to version 15,
which works around a breaking change that snuck into the latest Node LTS
versions.

Unfortunately, this version of nyc appears to break Node 8 and 9. We
need to work around this problem by skipping test coverage on those
versions.

Fixes #1130
nfischer added a commit that referenced this issue Nov 12, 2023
No change to logic. This updates nyc (code coverage tool) to version 15,
which works around a breaking change that snuck into the latest Node LTS
versions.

Unfortunately, this version of nyc appears to break Node 8 and 9. We
need to work around this problem by skipping test coverage on those
versions.

Fixes #1130
nfischer added a commit that referenced this issue Nov 12, 2023
No change to logic. This updates nyc (code coverage tool) to version 15,
which works around a breaking change that snuck into the latest Node LTS
versions.

Unfortunately, this version of nyc appears to break Node 8 and 9. We
need to work around this problem by skipping test coverage on those
versions.

Fixes #1130
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant