# Kibana startup fails - Cannot find module 'source-map'

**URL:** <https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501>\
**Category:** Kibana\
**Created:** [January 6, 2016, 11:38am UTC](https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501 "2016-01-06T11:38:23Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![danleong](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@danleong](https://discuss.elastic.co/u/danleong)\
**Post date:** [January 6, 2016, 11:38am UTC](https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501/1 "2016-01-06T11:38:23Z")

</div>

Anyone else got this, and know a fix for it?

```
$ ./bin/kibana plugin --install elastic/sense
Installing sense
Attempting to extract from https://download.elastic.co/elastic/sense/sense-latest.tar.gz
Downloading 318236 bytes....................
Extraction complete
Optimizing and caching browser bundles...
Plugin installation complete
$ ./bin/kibana
  log [10:42:29.255] [info][optimize] Optimizing and caching bundles for sense, kibana and statusPage. This may take a few minutes
  log [10:43:14.232] [fatal] Error: Optimizations failure.

    ERROR in ./src/ui/public/styles/dark-variables.less
    Module build failed: ModuleBuildError: Module build failed: Cannot find module 'source-map'
     @ undefined (line undefined, column undefined)
        at DependenciesBlock.onModuleBuildFailed (/Users/dan/kibana-4.3.1-darwin-x64/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:315:19)
...

```

Versions :-

OSX 10.10.5  
Java 8u66  
Node v0.12.3  
elasticsearch-2.1.1  
kibana-4.3.1-darwin-x64

I was just following the docs at [https://www.elastic.co/guide/en/elasticsearch/guide/current/running-elasticsearch.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/running-elasticsearch.html) ☹

Update :-

- Tried a clean install without Sense plugin - same error
- Tried upgrading to node 0.12.9 which is mentioned in the package.json - same error
- Tried "npm cache clear" first - same error
- nvm install v4.2.4 (official stable version) - same error

There's multiple errors - seems to be all failing when optimising all the Less files.

---

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [January 7, 2016, 7:49pm UTC](https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501/2 "2016-01-07T19:49:08Z")

</div>

Are you running a development version of Kibana, or the 4.3.1 build from the website?

If you're running a build that you downloaded, it ships with its own version of nodejs, which should include everything it needs to run.

---

<div class="post-metadata">

**Author:** ![danleong](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@danleong](https://discuss.elastic.co/u/danleong)\
**Post date:** [January 8, 2016, 9:29am UTC](https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501/3 "2016-01-08T09:29:32Z")

</div>

Sadly it's the 4.3.1 version from the website.

I tried renaming the node folder in the distribution to node.bak, so that  
the startup script uses my locally installed version instead. Still no  
luck. I assume there's something odd with the node\_modules supplied,  
perhaps conflicting with a global installed module that I have somewhere.

Didn't really need Kibana right now anyway 🙂

---

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [January 8, 2016, 4:29pm UTC](https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501/4 "2016-01-08T16:29:22Z")

</div>

You definitely **do not** want to use the system node install. We ship with it for a reason; we've tested it and know that it's ready to go.

It is possible we shipped with an issue here, but I'm pretty sure when we QA'd that release, we tested it with a number of plugins, Sense included. I'll spend a little time today trying to recreate your issue, just to be sure...

---

<div class="post-metadata">

**Author:** ![danleong](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@danleong](https://discuss.elastic.co/u/danleong)\
**Post date:** [January 8, 2016, 4:45pm UTC](https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501/5 "2016-01-08T16:45:16Z")

</div>

No need - I think I've figured it out!

Something you just wrote must have triggered a useful thought in my head ... I checked my environment and remembered I had NODE\_ENV=development set.

export NODE\_ENV=production

Voila! It works. Perhaps the distributed bin/kibana script needs to warn about running in "development" mode?

---

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [January 8, 2016, 5:51pm UTC](https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501/6 "2016-01-08T17:51:10Z")

</div>

Great, glad you got it working.

The build should be running in production mode by default, so I'm not sure why you had to explicitly specify that. I wonder if it's related to that bug I linked to or not, it's possible that it's still falling back to your system version of node, which it should not do from the build...

---

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [January 8, 2016, 5:56pm UTC](https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501/7 "2016-01-08T17:56:53Z")

</div>

Hrm, maybe I'm wrong about the cause. There's a bit in the server start config that uses the NODE\_ENV and falls back to production if it's not set. [https://github.com/elastic/kibana/blob/53d3abc21cb573813805c60ffae79e11df3dbf8e/src/server/config/Config.js#L84](https://github.com/elastic/kibana/blob/53d3abc21cb573813805c60ffae79e11df3dbf8e/src/server/config/Config.js#L84)

So if you have a global NODE\_ENV setting on your machine, that could be causing this issue.

---

<div class="post-metadata">

**Author:** ![AndyPotanin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andypotanin/32/7192_2.png) [@AndyPotanin](https://discuss.elastic.co/u/AndyPotanin)\
**Post date:** [January 16, 2016, 10:54am UTC](https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501/8 "2016-01-16T10:54:28Z")

</div>

I had some issue with running the server and the issue was also caused by NODE\_ENV being set to development. So the following works to work around this:

`NODE_ENV=production bin/kibana`

---

<div class="post-metadata">

**Author:** ![David\_Greenwell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_greenwell/32/62482_2.png) [@David\_Greenwell](https://discuss.elastic.co/u/David_Greenwell)\
**Post date:** [April 5, 2016, 8:34pm UTC](https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501/9 "2016-04-05T20:34:11Z")

</div>

I was having the same issue with my global NODE\_ENV setting as development, setting it to production worked for me.

---

<div class="post-metadata">

**Author:** ![gongsy945](https://avatars.discourse-cdn.com/v4/letter/g/858c86/32.png) [@gongsy945](https://discuss.elastic.co/u/gongsy945)\
**Post date:** [June 27, 2016, 10:59am UTC](https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501/10 "2016-06-27T10:59:39Z")

</div>

cd /usr/local/Cellar/kibana/4.5.1 ----your dir  
and npm install source-map

bingo!

---

<div class="post-metadata">

**Author:** ![arieljake](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@arieljake](https://discuss.elastic.co/u/arieljake)\
**Post date:** [July 12, 2016, 9:24pm UTC](https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501/11 "2016-07-12T21:24:48Z")

</div>

This is still the case. Kind of a problem, no?

Devs with this set for apps we are developing can't necessarily unset this (except on projects using dotenv).

---

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [July 12, 2016, 10:01pm UTC](https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501/12 "2016-07-12T22:01:34Z")

</div>

Yeah, I agree that the requirement to specify `NODE_ENV` isn't great. And I haven't run into it myself, but I'm guessing it's still a problem in the latest version too (4.5.2).

I'd encourage you to [open an issue](https://github.com/elastic/kibana/issues/) for it, and include some information about your specific case.

In the meantime, you _can_ set `NODE_ENV` for just Kibana as part of the startup command, instead of changing it system-wide, as @AndyPotanin pointed out above. However, if you are using one of the packages, you'll likely have to stop the service and run the binary by hand with the production setting. There may be a way to specify it in the startup script too, but I'm not well versed in Linux startup scripts.

---

<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 6, 2017, 1:47pm UTC](https://discuss.elastic.co/t/kibana-startup-fails-cannot-find-module-source-map/38501/13 "2017-07-06T13:47:06Z")

</div>


