You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having a minimalistic project consisting of cypress, lint-staged and npm-force-resolutions causes a reproducable ERR_REQUIRE_ESM error upon installing node modules.
How to reproduce
Given the fact that these modules (cypress, lint-staged and npm-force-resolutions) need to be installed, the following package.json allows one to reproduce the problem:
278 error /Users/Anonymous/Code/sample-error/node_modules/listr2/node_modules/slice-ansi/index.js:2
278 error const isFullwidthCodePoint = require('is-fullwidth-code-point');
278 error ^
278 error
278 error Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/Anonymous/Code/sample-error/node_modules/is-fullwidth-code-point/index.js from /Users/Anonymous/Code/sample-error/node_modules/listr2/node_modules/slice-ansi/index.js not supported.
278 error Instead change the require of /Users/Anonymous/Code/sample-error/node_modules/is-fullwidth-code-point/index.js in /Users/Anonymous/Code/sample-error/node_modules/listr2/node_modules/slice-ansi/index.js to a dynamic import() which is available in all CommonJS modules.
278 error at Object.<anonymous> (/Users/Anonymous/Code/sample-error/node_modules/listr2/node_modules/slice-ansi/index.js:2:30)
278 error at Object.<anonymous> (/Users/Anonymous/Code/sample-error/node_modules/listr2/node_modules/cli-truncate/index.js:2:19)
278 error at Object.<anonymous> (/Users/Anonymous/Code/sample-error/node_modules/listr2/dist/renderer/default.renderer.js:4:21)
278 error at Object.<anonymous> (/Users/Anonymous/Code/sample-error/node_modules/listr2/dist/utils/renderer.js:4:28)
278 error at Object.<anonymous> (/Users/Anonymous/Code/sample-error/node_modules/listr2/dist/lib/task.js:11:20)
278 error at Object.<anonymous> (/Users/Anonymous/Code/sample-error/node_modules/listr2/dist/listr.js:7:16)
278 error at Object.<anonymous> (/Users/Anonymous/Code/sample-error/node_modules/listr2/dist/index.js:13:14)
278 error at Object.<anonymous> (/Users/Anonymous/Code/sample-error/node_modules/cypress/lib/tasks/install.js:17:5)
278 error at Object.<anonymous> (/Users/Anonymous/Code/sample-error/node_modules/cypress/index.js:16:5) {
278 error code: 'ERR_REQUIRE_ESM'
278 error }
279 verbose exit 1
The text was updated successfully, but these errors were encountered:
npm-force-resolutions creates a mapping which confuses npm (at the time of writing this was tested with version 8.1.2 through 8.5.5).
Inside the lockfile a node called packages differs completely from a working lockfile.
Sorting the resulting lockfile from npm-force-resolutions (for example with: jq . --sort-keys package-lock.json.npmforceresolutions > package-lock.json) results in a working version.
EDIT: This means the solution is, that the lockfile packages node must be sorted afterwards
Having a minimalistic project consisting of
cypress
,lint-staged
andnpm-force-resolutions
causes a reproducableERR_REQUIRE_ESM
error upon installing node modules.How to reproduce
Given the fact that these modules (
cypress
,lint-staged
andnpm-force-resolutions
) need to be installed, the following package.json allows one to reproduce the problem:With the following command the error is reproducible and shall simulate the execution upon a pipeline
Error output
The text was updated successfully, but these errors were encountered: