I want to use the sawtooth-sdk, and the guide code (https://sawtooth.hyperledger.org/docs/core/releases/latest/_autogen/sdk_submit_tutorial_js.html):
const {createContext, CryptoFactory} = require('sawtooth-sdk/signing')
const context = createContext('secp256k1')
const privateKey = context.newRandomPrivateKey()
const signer = CryptoFactory(context).newSigner(privateKey)
but error:
TypeError: Class constructor CryptoFactory cannot be invoked without 'new'
As the error states, you should change:
const signer = CryptoFactory(context).newSigner(privateKey)
to:
const signer = (new CryptoFactory(context)).newSigner(privateKey)