-
Notifications
You must be signed in to change notification settings - Fork 12
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
ESM import issue #228
Comments
Can you give me a reproducible example showing the problem. I can’t with that botched Node ESM anymore Sent from my iPhoneOn Jan 23, 2024, at 10:53, Sam Tsai ***@***.***> wrote:
The command fails on importing of cypress.config.ts
DEBUG=find-cypress-specs npx find-cypress-specs --branch main
Need to install the following packages:
***@***.***
Ok to proceed? (y)
find-cypress-specs arguments { _: [], '--branch': 'main' } +0ms
find-cypress-specs found file cypress.config.ts +0ms
find-cypress-specs loading Cypress config from /Users/username/Code/firepower-test-library/cypress.config.ts +127ms
/Users/username/.npm/_npx/7109e851be596cd4/node_modules/ts-node/dist-raw/node-internal-errors.js:46
const err = new Error(getErrRequireEsmMessage(filename, parentPath, packageJsonPath))
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/username/Code/firepower-test-library/cypress.config.ts
require() of ES modules is not supported.
require() of /Users/username/Code/firepower-test-library/cypress.config.ts from /Users/username/.npm/_npx/7109e851be596cd4/node_modules/require-and-forget/src/index.js is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
Instead change the requiring code to use import(), or remove "type": "module" from /Users/username/Code/firepower-test-library/package.json.
at createErrRequireEsm (/Users/username/.npm/_npx/7109e851be596cd4/node_modules/ts-node/dist-raw/node-internal-errors.js:46:15)
at assertScriptCanLoadAsCJSImpl (/Users/username/.npm/_npx/7109e851be596cd4/node_modules/ts-node/dist-raw/node-internal-modules-cjs-loader.js:584:11)
at Object.require.extensions.<computed> [as .ts] (/Users/username/.npm/_npx/7109e851be596cd4/node_modules/ts-node/src/index.ts:1610:5)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Function.Module._load (node:internal/modules/cjs/loader:938:12)
at Module.require (node:internal/modules/cjs/loader:1115:19)
at require (node:internal/modules/helpers:130:18)
at requireAndForget (/Users/username/.npm/_npx/7109e851be596cd4/node_modules/require-and-forget/src/index.js:28:17)
at getConfigTs (/Users/username/.npm/_npx/7109e851be596cd4/node_modules/find-cypress-specs/src/index.js:51:25)
at getConfig (/Users/username/.npm/_npx/7109e851be596cd4/node_modules/find-cypress-specs/src/index.js:87:12) {
code: 'ERR_REQUIRE_ESM'
}
pacakge.json is set to "type": "module"
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Sure, let me work on a smaller reproducible example. |
https://github.com/samtsai/cypress-test-tiny/tree/typescript-esm-import-issue I think the issue is actually in |
Seeing the same issue as @samtsai, we hoped to migrate our org's Cypress codebase from CommonJS to ES Module but after updating the The error produced is the same as noted above (here is a short version):
With a trace to line 28 of the |
See some relevant notes: cc @bahmutov |
🎉 This issue has been resolved in version 1.42.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
The command fails on importing of
cypress.config.ts
pacakge.json
is set to"type": "module"
The text was updated successfully, but these errors were encountered: