Question: I am trying to implement [elasticsearch.js](https://github.com/elastic/elasticsearch-js) in my project and when I added:

```
 var elasticsearch = require('elasticsearch');

```

It broke my project and said require is not defined. I did research and saw that I would have to use a library called require.js within my project but that is changing my whole project structure just for one script. 

I wanted to see if anybody knows how to call an instance without using require:

```
 var elasticsearch = require('elasticsearch');
 var client = new elasticsearch.Client();

```

Answer: 
You seem to be following the instructions for using elasticsearch in a node project or using a bundling system that supports CJS modules (like browserify or webpack). If you want a script that's for a browser-only project, see the [Browser Builds](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/browser-builds.html) page.

Note that at this time, they have this note:

> 
> These versions of the client are currently experimental.
> 
> 
>
You're using a version that should be used in a node project or through a module loader/bundler. The `require` keyword is node specific, the browser has no idea what to do with it. Require.js would help, you can also install Rollup or Webpack which would bundle the CJS (require) dependencies and your code into one file. 

Or to be simple just go to <https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/browser-builds.html> as Jacob said