# APM NodeJS default code is resulting in error

**URL:** <https://discuss.elastic.co/t/apm-nodejs-default-code-is-resulting-in-error/213886>\
**Category:** APM\
**Tags:** nodejs\
**Created:** [January 6, 2020, 12:07pm UTC](https://discuss.elastic.co/t/apm-nodejs-default-code-is-resulting-in-error/213886 "2020-01-06T12:07:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![moscha](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@moscha](https://discuss.elastic.co/u/moscha)\
**Post date:** [January 6, 2020, 12:07pm UTC](https://discuss.elastic.co/t/apm-nodejs-default-code-is-resulting-in-error/213886/1 "2020-01-06T12:07:20Z")

</div>

Hello all.

I installed the newest version of APM Server on a machine and I am trying to test an apm agent on another machine. The code is very simple, and I took it straight from Elastic's example:

```
var apm = require('elastic-apm-node').start({
serviceName: 'testapp',
serverUrl: 'http://192.168.0.180:8200'
})

const express = require('express')
const app = express()
app.get('/', (req, res) => {
 res.send('HEY!')
})
app.listen(3000, () => console.log('Server running on port 3000'))

```

I tried to delete some line of the code to test where it crashes, and I think it's on the beggining of the file, i.e: var apm = require('elastic-apm-node').start({

The exact error I get is:

```
/home/user/test/node_modules/read-pkg-up/index.js:6
module.exports = async options => {
                       ^^^^^^^

SyntaxError: Unexpected identifier
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/user/test/node_modules/elastic-apm-node/lib/config.js:8:17)

```

Does anybody get any idea?

---

<div class="post-metadata">

**Author:** ![wa7son](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wa7son/32/21259_2.png) [@wa7son](https://discuss.elastic.co/u/wa7son)\
**Post date:** [January 6, 2020, 12:23pm UTC](https://discuss.elastic.co/t/apm-nodejs-default-code-is-resulting-in-error/213886/2 "2020-01-06T12:23:30Z")

</div>

Looks like you're using an unsupported version of Node.js. Version 3.x of the Elastic APM Node.js Agent supports 8.6.0 and higher. Can you confirm which version of Node.js you're using?

For support of Node.js 6.x, you need to use version 2.x of the Elastic APM Node.js Agent, but it is highly recommended at you upgrade your Node.js version to at least version 10.x at this point to get the latest security patches.

---

<div class="post-metadata">

**Author:** ![moscha](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@moscha](https://discuss.elastic.co/u/moscha)\
**Post date:** [January 6, 2020, 12:33pm UTC](https://discuss.elastic.co/t/apm-nodejs-default-code-is-resulting-in-error/213886/3 "2020-01-06T12:33:31Z")

</div>

> [@moscha](#):
>
> serviceName: 'testapp', serverUrl: '[http://192.168.0.180:8200](http://192.168.0.180:8200)'

Thank you very much! That was the problem!! I Installed a newer version and it works!  
Thank you again!

---

<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:** [January 27, 2020, 8:33am UTC](https://discuss.elastic.co/t/apm-nodejs-default-code-is-resulting-in-error/213886/4 "2020-01-27T08:33:31Z")

</div>

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