running npm script from within npm script fails with ESM error

here are the scripts from my package.json:
"scripts": {
"build": "next build",
"dev": "next dev",
"lint": "next lint",
"start": "next start",
"test:run": "vitest",
"test": "firebase emulators:exec 'npm run test:run'"
},
"scripts": {
"build": "next build",
"dev": "next dev",
"lint": "next lint",
"start": "next start",
"test:run": "vitest",
"test": "firebase emulators:exec 'npm run test:run'"
},
when I run npm run test I get the following error:
> firebase emulators:exec 'npm run test:run'

i emulators: Starting emulators: auth, firestore, storage
i firestore: Firestore Emulator logging to firestore-debug.log
✔ firestore: Firestore Emulator UI websocket is running on 9150.
i Running script: npm run test:run

> [email protected] test:run /Users/tom/Development/projects/t3-true-finals
> vitest

node:internal/modules/cjs/loader:979
throw new ERR_REQUIRE_ESM(filename, true);
^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/tom/Development/projects/t3-true-finals/node_modules/vitest/vitest.mjs not supported.
Instead change the require of /Users/tom/Development/projects/t3-true-finals/node_modules/vitest/vitest.mjs to a dynamic import() which is available in all CommonJS modules.
at Function.runMain (pkg/prelude/bootstrap.js:1983:12) {
code: 'ERR_REQUIRE_ESM'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:run: `vitest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:run 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! /Users/tom/.npm/_logs/2023-03-03T02_28_14_203Z-debug.log
> firebase emulators:exec 'npm run test:run'

i emulators: Starting emulators: auth, firestore, storage
i firestore: Firestore Emulator logging to firestore-debug.log
✔ firestore: Firestore Emulator UI websocket is running on 9150.
i Running script: npm run test:run

> [email protected] test:run /Users/tom/Development/projects/t3-true-finals
> vitest

node:internal/modules/cjs/loader:979
throw new ERR_REQUIRE_ESM(filename, true);
^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/tom/Development/projects/t3-true-finals/node_modules/vitest/vitest.mjs not supported.
Instead change the require of /Users/tom/Development/projects/t3-true-finals/node_modules/vitest/vitest.mjs to a dynamic import() which is available in all CommonJS modules.
at Function.runMain (pkg/prelude/bootstrap.js:1983:12) {
code: 'ERR_REQUIRE_ESM'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:run: `vitest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:run 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! /Users/tom/.npm/_logs/2023-03-03T02_28_14_203Z-debug.log
1 Reply
Tom
Tom2y ago
wish i could change the typo in the title unfortunate in case anyone was wondering the version of the cloud firestore emulator suite that the instructions tell you to download screws this up, but the version from brew works correctly
Want results from more Discord servers?
Add your server