• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const { mustCall, isWindows } = require('../common');
4const fixtures = require('../common/fixtures');
5const { spawn } = require('child_process');
6const { strictEqual, ok } = require('assert');
7
8const entry = fixtures.path('/es-modules/import-invalid-pjson.mjs');
9const invalidJson = fixtures.path('/node_modules/invalid-pjson/package.json');
10
11const child = spawn(process.execPath, [entry]);
12child.stderr.setEncoding('utf8');
13let stderr = '';
14child.stderr.on('data', (data) => {
15  stderr += data;
16});
17child.on('close', mustCall((code, signal) => {
18  strictEqual(code, 1);
19  strictEqual(signal, null);
20  ok(
21    stderr.includes(
22      `[ERR_INVALID_PACKAGE_CONFIG]: Invalid package config ${invalidJson} ` +
23      `while importing "invalid-pjson" from ${entry}. ` +
24      `Unexpected token } in JSON at position ${isWindows ? 16 : 14}`
25    ),
26    stderr);
27}));
28