# APM agent an Typescript

**URL:** <https://discuss.elastic.co/t/apm-agent-an-typescript/235952>\
**Category:** APM\
**Tags:** nodejs\
**Created:** [June 5, 2020, 1:04pm UTC](https://discuss.elastic.co/t/apm-agent-an-typescript/235952 "2020-06-05T13:04:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ffknob](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ffknob/32/37008_2.png) [@ffknob](https://discuss.elastic.co/u/ffknob)\
**Post date:** [June 5, 2020, 1:04pm UTC](https://discuss.elastic.co/t/apm-agent-an-typescript/235952/1 "2020-06-05T13:04:40Z")

</div>

Hello.

I'm trying to use APM in a Node+Express+Typescript backend. I followed this:

[https://www.elastic.co/guide/en/apm/agent/nodejs/current/es-modules.html](https://www.elastic.co/guide/en/apm/agent/nodejs/current/es-modules.html)

So now I have this on my `tsconfig.json`:

```auto
"esModuleInterop": true,

```

And in my `app.ts` I try to start the agent like this:

```auto
import apm from 'elastic-apm-node/start';

const apmClient = apm.start({
    serviceName:
        process.env.ELASTIC_APM_SERVICE_NAME || 'elastic-apm-demo-middleware',
    serverUrl: process.env.ELASTIC_APM_SERVER_URL || 'http://apm-server:8200',
    secretToken: process.env.ELASTIC_APM_SECRET_TOKEN || '',
    logUncaughtExceptions: true
});

```

Problems:

1. It generates an error, which is sent to the APM server: `Do not call .start() more than once`
2. It points to the wrong line... I guess this is due the transpilation process, so I'll have to find how to publish the source maps...

What am I not getting right in the agent's start process?

Thank you

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 26, 2020, 9:04am UTC](https://discuss.elastic.co/t/apm-agent-an-typescript/235952/2 "2020-06-26T09:04:46Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
