[Pkg-javascript-devel] Bug#994137: eslint: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /usr/share/nodejs/strip-json-comments/index.js

Simon McVittie smcv at debian.org
Sun Sep 12 16:09:21 BST 2021


Package: eslint
Version: 5.16.0~dfsg+~4.16.8-5
Severity: grave
Justification: renders package unusable
Control: affects -1 gnome-shell-extension-appindicator
X-Debbugs-Cc: node-strip-json-comments at packages.debian.org

Original steps to reproduce: rebuild gnome-shell-extension-appindicator

Minimized steps to reproduce: eslint --version

Expected result: eslint runs

Actual result:

> user at host:~$ eslint --version
> internal/modules/cjs/loader.js:1015
>       throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
>       ^
> 
> Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /usr/share/nodejs/strip-json-comments/index.js
> require() of ES modules is not supported.
> require() of /usr/share/nodejs/strip-json-comments/index.js from /usr/share/nodejs/eslint/lib/config/config-file.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
> Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /usr/share/nodejs/strip-json-comments/package.json.
> 
>     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1015:13)
>     at Module.load (internal/modules/cjs/loader.js:863:32)
>     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
>     at Module.require (internal/modules/cjs/loader.js:887:19)
>     at require (internal/modules/cjs/helpers.js:74:18)
>     at Object.<anonymous> (/usr/share/nodejs/eslint/lib/config/config-file.js:19:21)
>     at Module._compile (internal/modules/cjs/loader.js:999:30)
>     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
>     at Module.load (internal/modules/cjs/loader.js:863:32)
>     at Function.Module._load (internal/modules/cjs/loader.js:708:14) {
>   code: 'ERR_REQUIRE_ESM'
> }

I'm not sure whether this is a bug in strip-json-comments, or a bug in
eslint. If this is considered to be a strip-json-comments bug, please
reassign. I suspect this is a regression triggered by the change that
closed #993167.

(The system info below is from a ssh login into a throwaway test VM where
I reproduced this bug, which is why my local is not yet set up correctly.)

I'm going to work around this by making gnome-shell-extension-appindicator
stop running eslint at build-time, which is probably a good change
regardless.

Thanks,
    smcv

-- System Information:
Debian Release: bookworm/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-8-amd64 (SMP w/2 CPU threads)
Locale: LANG=en_GB.utf8, LC_CTYPE=C.UTF-8 (charmap=locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages eslint depends on:
ii  node-ajv                                6.12.6-2
ii  node-concat-stream                      2.0.0-1
ii  node-debug                              4.3.1+~cs4.1.5-1
ii  node-doctrine                           3.0.0-3
ii  node-eslint-scope                       5.1.1-1
ii  node-eslint-utils                       2.1.0-3
ii  node-eslint-visitor-keys [node-types-e  2.0.0+~0.0.45-1
ii  node-espree                             7.3.1~dfsg1-1
ii  node-esquery                            1.3.1~ds-4
ii  node-estraverse                         5.2.0-1
ii  node-esutils                            2.0.3-1
ii  node-file-entry-cache                   6.0.0+~3.0.4+~2.0.0+~1.0.0+~2.0.1-1
ii  node-functional-red-black-tree          1.0.1+20181105-5
ii  node-glob                               7.1.7+~cs7.5.19-2
ii  node-globals                            13.5.0-1
ii  node-ignore                             5.1.4-6
ii  node-imurmurhash                        0.1.4-1.1
ii  node-json-schema [node-types-json-sche  0.3.0+~7.0.6-1
ii  node-json-stable-stringify              1.0.1+~cs5.1.32-1
ii  node-levn                               0.3.0+dfsg-4
ii  node-lodash                             4.17.21+dfsg+~cs8.31.189.20210220-2
ii  node-mkdirp                             1.0.4+~1.0.1-1
ii  node-optionator                         0.9.1+dfsg-1
ii  node-path-is-inside                     1.0.2-1.1
ii  node-progress                           2.0.3-1
ii  node-regenerate-unicode-properties      8.2.0+ds-2
ii  node-regexpp                            3.1.0-5
ii  node-resolve-from [node-import-fresh]   5.0.0+~3.1.0+~3.3.0+~2.0.0-1
ii  node-semver                             7.3.4-1
ii  node-strip-json-comments                4.0.0-2
ii  nodejs                                  12.22.5~dfsg-2

Versions of packages eslint recommends:
ii  node-chalk       4.1.0-1
pn  node-inquirer    <none>
ii  node-js-yaml     3.14.1+dfsg+~3.12.6-2
ii  node-strip-ansi  6.0.0-2
pn  node-text-table  <none>

Versions of packages eslint suggests:
pn  node-babel-code-frame  <none>
pn  node-babel-eslint      <none>
ii  node-esprima           4.0.1+ds+~4.0.3-1
pn  node-esprima-fb        <none>
pn  node-table             <none>

-- debconf information:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "C.UTF-8",
	LANG = "en_GB.utf8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory



More information about the Pkg-javascript-devel mailing list