Open
Description
Unable to use node-opcua-pki in an ESM repo
Command:
npx node-opcua-pki certificate --dns dns --applicationUri 'urn:app:uri' --validity 365 --selfSigned --output /certificates/opcua.pem --privateKey /certificates/opcua.key
Error:
require() of ES Module /workspaces/xxx/certificates/config.js from /workspaces/xxx/node_modules/node-opcua-pki/dist/lib/ca/crypto_create_CA.js not supported.
config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /workspaces/xxx/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
It also generates a config.js
file in my certificates folder rather than the certificates
Is there a workaround since this project is not ESM?
Activity