secret-shield
secret-shield copied to clipboard
Secret-shield throws exception
What repository are you running secret-shield on?
Mapbox private repo.
What version of secret-shield are you running?
How did you invoke secret-shield?
pre-commit
How is secret-shield not working as expected?
When I invoke command secret-shield --add-hooks global I got an error:
internal/modules/cjs/loader.js:1102
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/pavel/.local/share/fnm/node-versions/v14.20.1/installation/lib/node_modules/@mapbox/secret-shield/node_modules/p-queue/dist/index.js
require() of ES modules is not supported.
require() of /home/pavel/.local/share/fnm/node-versions/v14.20.1/installation/lib/node_modules/@mapbox/secret-shield/node_modules/p-queue/dist/index.js from /home/pavel/.local/share/fnm/node-versions/v14.20.1/installation/lib/node_modules/@mapbox/secret-shield/searchRepo.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 /home/pavel/.local/share/fnm/node-versions/v14.20.1/installation/lib/node_modules/@mapbox/secret-shield/node_modules/p-queue/package.json.
at new NodeError (internal/errors.js:322:7)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at Object.<anonymous> (/home/pavel/.local/share/fnm/node-versions/v14.20.1/installation/lib/node_modules/@mapbox/secret-shield/searchRepo.js:3:16)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32) {
cod
```e: 'ERR_REQUIRE_ESM'
}
Used node v14.20.1.
I've got similar problem, installed secret-shield but got an error during its startup:
$ node --version
v16.14.0
$ npm --version
8.15.1
$ mbx --version
5.0.2
$ npm list -g | grep 'secret-shield'
├── @mapbox/[email protected] -> ./../../../home/antonnovikau/Projects/secret-shield
$ secret-shield --add-hooks global
/Projects/secret-shield/searchRepo.js:3
const PQueue = require('p-queue');
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/antonnovikau/Projects/secret-shield/node_modules/p-queue/dist/index.js from /home/antonnovikau/Projects/secret-shield/searchRepo.js not supported.
Instead change the require of index.js in /home/antonnovikau/Projects/secret-shield/searchRepo.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/home/antonnovikau/Projects/secret-shield/searchRepo.js:3:16)
at Object.<anonymous> (/home/antonnovikau/Projects/secret-shield/bin/secret-shield.js:20:20) {
code: 'ERR_REQUIRE_ESM'
}
It worked up to commit 2745aa7eecbd962749a805a41c82f41b82a2d3f8
.
Then it failed with commit 81329131d88210b04c184efc2408bc4bffd10bde
when we upgraded p-queue
and more in #32.
We're looking into it.
fixed by #40
@gatoroto , @globaltrouble , can you please confirm it's fixed now?
@ThibaudLopez helped for me, now I can execute
secret-shield --add-hooks global
without any errors. Thanks!
Confirm fix, thanks!