Skip to content

ESM Support #42

Open
Open
@kevin-brashears-fhr

Description

@kevin-brashears-fhr

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @kevin-brashears-fhr

        Issue actions

          ESM Support · Issue #42 · node-opcua/node-opcua-pki