If you are using ES Modules,
for instance with the help of Babel,
--experimental-modules flag for Node.js,
all import statements are evaluated prior to calling any functions.
In this case, you can’t configure the agent by passing a configuration object to the
as this call will happen after all of the modules have been loaded.
Instead you need to import the
import apm from 'elastic-apm-node/start'
To explicitly start the agent you need to import
elastic-apm-node and call the
apm.start() method with the
agent configuration object.
If you’re using TypeScript,
the default import will not work unless you use the
esModuleInterop compiler option.
If you don’t want to switch on
you instead have to import the agent like so:
import * as apm from 'elastic-apm-node/start'