PR-URL: https://github.com/nodejs/node/pull/35117 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
27 lines
874 B
JavaScript
27 lines
874 B
JavaScript
'use strict';
|
|
|
|
const { mustCall, isWindows } = require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
const { spawn } = require('child_process');
|
|
const { strictEqual, ok } = require('assert');
|
|
|
|
const entry = fixtures.path('/es-modules/import-invalid-pjson.mjs');
|
|
const invalidJson = fixtures.path('/node_modules/invalid-pjson/package.json');
|
|
|
|
const child = spawn(process.execPath, [entry]);
|
|
child.stderr.setEncoding('utf8');
|
|
let stderr = '';
|
|
child.stderr.on('data', (data) => {
|
|
stderr += data;
|
|
});
|
|
child.on('close', mustCall((code, signal) => {
|
|
strictEqual(code, 1);
|
|
strictEqual(signal, null);
|
|
ok(
|
|
stderr.includes(
|
|
`[ERR_INVALID_PACKAGE_CONFIG]: Invalid package config ${invalidJson} ` +
|
|
`while importing "invalid-pjson" from ${entry}. ` +
|
|
`Unexpected token } in JSON at position ${isWindows ? 16 : 14}`
|
|
),
|
|
stderr);
|
|
}));
|