# Cannot find module 'elastic-apm-node'

**URL:** <https://discuss.elastic.co/t/cannot-find-module-elastic-apm-node/239017>\
**Category:** APM\
**Tags:** nodejs\
**Created:** [June 28, 2020, 2:09pm UTC](https://discuss.elastic.co/t/cannot-find-module-elastic-apm-node/239017 "2020-06-28T14:09:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ckough](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ckough/32/61892_2.png) [@ckough](https://discuss.elastic.co/u/ckough)\
**Post date:** [June 28, 2020, 2:09pm UTC](https://discuss.elastic.co/t/cannot-find-module-elastic-apm-node/239017/1 "2020-06-28T14:09:37Z")

</div>

Hi there

I'm new to Elastic APM and I'm using ELK and App server 7.7. I've managed to get APM to talk to ELK.

I've been tasked to monitor Node.JS and I thought I'll start by simply monitoring a simple 'Hello World' code.

I'm using a simple code in app.js like so:

```auto
const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

```

How do I get a Node JS agent to monitor this?

I have installed agent like so in an offline machine:

```auto
sudo npm install elastic-apm-node-3.6.1.tgz --save

```

I do not know if this is correct since I can't find any doc to show me how to install agent in an offline manner.

I have inserted the following code at the top of app.js:

```auto
// Add this to the VERY top of the first file loaded in your app
var apm = require('elastic-apm-node').start({
  // Override service name from package.json
  // Allowed characters: a-z, A-Z, 0-9, -, _, and space
  serviceName: 'testApp',

  // Use if APM Server requires a token
  secretToken: '',

  // Set custom APM Server URL (default: http://localhost:8200)
  serverUrl: 'http://10.10.10.10:8200'
})

```

Again I do not know if this is correct since I'm not familiar with Node.JS and the doc seems to assume I have a fair grasp of it.

When I run "node app.js", I get the following error:

```auto
Error: Cannot find module 'elastic-apm-node'
    at Function.Module._resolveFilename (module.js:476:15)
    at Function.Module._load (module.js:424:25)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/user/app.js:1:101)
    at Module._compile (module.js:577:32)
    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)

```

Again I do not know if this is even the correct way to insert code but I can't get any more clue out of the documentation.

Can anyone pls assist me? Any step by step instruction will be really helpful. Thanks.

ck

---

<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:** [July 19, 2020, 10:09am UTC](https://discuss.elastic.co/t/cannot-find-module-elastic-apm-node/239017/2 "2020-07-19T10:09:37Z")

</div>

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