1import { spawnPromisified } from '../common/index.mjs'; 2import * as fixtures from '../common/fixtures.mjs'; 3import assert from 'node:assert'; 4import { execPath } from 'node:process'; 5import { describe, it } from 'node:test'; 6 7 8describe('ESM: nonexistent loader', () => { 9 it('should throw', async () => { 10 const { code, stderr } = await spawnPromisified(execPath, [ 11 '--experimental-loader', 12 'i-dont-exist', 13 fixtures.path('print-error-message.js'), 14 ]); 15 16 assert.notStrictEqual(code, 0); 17 18 // Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'i-dont-exist' imported from 19 assert.match(stderr, /ERR_MODULE_NOT_FOUND/); 20 assert.match(stderr, /'i-dont-exist'/); 21 22 assert.ok(!stderr.includes('Bad command or file name')); 23 }); 24}); 25