# Importing ES6 files outside of app folder

**URL:** <https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150>\
**Category:** Ember CLI\
**Created:** [June 5, 2015, 3:16pm UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150 "2015-06-05T15:16:30Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisbateman](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/chrisbateman/32/10962_2.png) [@chrisbateman](https://discuss.emberjs.com/u/chrisbateman)\
**Post date:** [June 5, 2015, 3:16pm UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/1 "2015-06-05T15:16:30Z")

</div>

I’d like to import an existing ES6 module into my app. If I copy it anywhere into the `app` folder, it works fine with a relative import path.

```
import test from '../utils/file';

```

However, if the file is in `vendor` or `bower_components` or `node_modules`, I get a “could not find module” error.

```
import test from 'vendor/file';

```

[This issue](https://github.com/ember-cli/ember-cli/issues/1352) is a bit old, but it gives the impression that this should work. Is there a solution for this?

---

<div class="post-metadata">

**Author:** ![artsmc88](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/artsmc88/32/15520_2.png) [@artsmc88](https://discuss.emberjs.com/u/artsmc88)\
**Post date:** [June 7, 2015, 6:22am UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/2 "2015-06-07T06:22:58Z")

</div>

Why don’t you just import it inside the brocfile.js. that should create the reference for you: app.import(‘bower\_components/…’);

---

<div class="post-metadata">

**Author:** ![chrisbateman](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/chrisbateman/32/10962_2.png) [@chrisbateman](https://discuss.emberjs.com/u/chrisbateman)\
**Post date:** [June 7, 2015, 3:52pm UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/3 "2015-06-07T15:52:42Z")

</div>

I tried that - but I get an “unexpected reserved word” error because the ES6 module doesn’t get transpiled.

The [last comment](https://github.com/ember-cli/ember-cli/issues/1352#issuecomment-72034348) on that issue says that shouldn’t be needed.

Between this issue and the fact that you also can’t pull in [unnamed AMD/UMD modules](https://github.com/ember-cli/ember-cli/issues/3563) (which are very common) - it seems incredibly difficult to pull 3rd-party modules into Ember CLI.

---

<div class="post-metadata">

**Author:** ![artsmc88](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/artsmc88/32/15520_2.png) [@artsmc88](https://discuss.emberjs.com/u/artsmc88)\
**Post date:** [June 8, 2015, 9:51pm UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/4 "2015-06-08T21:51:10Z")

</div>

> [@chrisbateman](#):
>
> ES6 module

Just curious any reason why this module needs to sit in the node\_modules?

The 2 approaches I have taken to this problem is one

1. place the modules in the bower\_components folder and then do the app.import I know I don’t get the benefit of installing it with bower install but it was something I could live with.
2. Place the module inside the app folder. I added a Util folder to my app to manage modules I write.

util/plugin.js

```
 import Ember from 'ember';

//Manages an object ajax request

import 'project/utils/plugins/apiRequest'; 

//Sets an active class to or takes away from targeted div

import 'project/utils/plugins/toogleActive'; 

//vaildate product fields

import 'project/utils/plugins/validateProduct'; 

```

Then of course I can reference those modules when i need them

```
import '../utils/plugins'; 

```

I’m not sure if this is the best route just the only one I have found to work. Im not exactly sure this fits your use case. but I was pretty frustrated with a similar problem for some time.

---

<div class="post-metadata">

**Author:** ![chrisbateman](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/chrisbateman/32/10962_2.png) [@chrisbateman](https://discuss.emberjs.com/u/chrisbateman)\
**Post date:** [June 8, 2015, 10:42pm UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/5 "2015-06-08T22:42:10Z")

</div>

@artsmc88 I never said it needs to sit in node\_modules. Please read my previous posts closely - app.import does not work for ES6 modules. My original post noted that placing the module inside the app folder works fine.

---

<div class="post-metadata">

**Author:** ![artsmc88](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/artsmc88/32/15520_2.png) [@artsmc88](https://discuss.emberjs.com/u/artsmc88)\
**Post date:** [June 9, 2015, 12:45am UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/6 "2015-06-09T00:45:58Z")

</div>

well I guess the simple answer to the question is no. you can use the other options or make a emberaddon. I dunno i think that placing it inside the app folder makes more sense for organization, so i was wondering if you had a use case?

---

<div class="post-metadata">

**Author:** ![chrisbateman](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/chrisbateman/32/10962_2.png) [@chrisbateman](https://discuss.emberjs.com/u/chrisbateman)\
**Post date:** [June 9, 2015, 4:45am UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/7 "2015-06-09T04:45:45Z")

</div>

The use case is: use an existing, 3rd-party ES6 module in an Ember app, without needing to manually move it into the app directory.

---

<div class="post-metadata">

**Author:** ![jackmatt2](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@jackmatt2](https://discuss.emberjs.com/u/jackmatt2)\
**Post date:** [August 15, 2015, 9:40am UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/8 "2015-08-15T09:40:04Z")

</div>

@chrisbateman I am facing a similar issue. I need to import an es6 file fro the vendor folder - did you ever get this working?

---

<div class="post-metadata">

**Author:** ![billdwhite](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/billdwhite/32/11269_2.png) [@billdwhite](https://discuss.emberjs.com/u/billdwhite)\
**Post date:** [August 18, 2015, 7:52pm UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/9 "2015-08-18T19:52:53Z")

</div>

Same here; I would expect that I can create an ES6 module, put it into the bower\_components directory and then have it transpiled automatically into the app somehow. This is something that should be really simple and has proven very frustrating. Simply put: if I have my own ES6 module, how to I use it in my ember app?

---

<div class="post-metadata">

**Author:** ![chrisbateman](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/chrisbateman/32/10962_2.png) [@chrisbateman](https://discuss.emberjs.com/u/chrisbateman)\
**Post date:** [August 19, 2015, 2:26pm UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/10 "2015-08-19T14:26:09Z")

</div>

@jackmatt2 Unfortunately not. We’ve elected to stay away from Ember for now, largely due to the inflexibility of the build process with issues like this.

I did, however, hear from @wycats that support would be coming soon: [https://twitter.com/wycats/status/617038351917420544](https://twitter.com/wycats/status/617038351917420544)

---

<div class="post-metadata">

**Author:** ![harimath](https://avatars.discourse-cdn.com/v4/letter/h/76d3ee/32.png) [@harimath](https://discuss.emberjs.com/u/harimath)\
**Post date:** [November 23, 2015, 7:46am UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/12 "2015-11-23T07:46:36Z")

</div>

> [@artsmc88](#):
>
> node\_modules

node\_modules

Any reason why you are asking if the module needs to sit in the node\_modules ? I mean can we not use app.import for node\_modules like we do for bower\_components ? If no, what is the correct way to use Node packages (or 3rd party libraries)?

---

<div class="post-metadata">

**Author:** ![ubuntuvim](https://avatars.discourse-cdn.com/v4/letter/u/a4c791/32.png) [@ubuntuvim](https://discuss.emberjs.com/u/ubuntuvim)\
**Post date:** [January 7, 2016, 11:12am UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/14 "2016-01-07T11:12:50Z")

</div>

I was directly in the Index.html to introduce the third party Library

---

<div class="post-metadata">

**Author:** ![jacobq](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jacobq/32/14827_2.png) [@jacobq](https://discuss.emberjs.com/u/jacobq)\
**Post date:** [April 29, 2016, 4:16pm UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/15 "2016-04-29T16:16:42Z")

</div>

Does anyone know if there has been any progress related to this? I am learning Ember and attempting to use it in my electron-based application but getting extremely mixed up between the various module systems, ES2015 import/export via Babel with Ember, require made available via electron, require made available via node, … Any help or advice would be appreciated.

---

<div class="post-metadata">

**Author:** ![mcfiredrill](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/mcfiredrill/32/15777_2.png) [@mcfiredrill](https://discuss.emberjs.com/u/mcfiredrill)\
**Post date:** [May 16, 2016, 8:34am UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/16 "2016-05-16T08:34:37Z")

</div>

I’m still using the process described here to import some es6 modules in `vendor/`, not sure if it still applies to es6 modules in `node_modules/`.

> **[Teaching ember-cli to talk to phoenix sockets](https://chrismcg.com/2015/07/04/teaching-ember-cli-to-talk-to-phoenix-sockets/)**
>
> Want to hook up an ember-cli frontend app to a backend phoenix app with websockets? This post shows you how (ember-cli 0.2.7, phoenix 0.14.0)

---

<div class="post-metadata">

**Author:** ![krukid](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/krukid/32/12510_2.png) [@krukid](https://discuss.emberjs.com/u/krukid)\
**Post date:** [August 11, 2016, 2:16pm UTC](https://discuss.emberjs.com/t/importing-es6-files-outside-of-app-folder/8150/17 "2016-08-11T14:16:49Z")

</div>

guess importing ES6 modules from vendor doesn’t work still. moved them to app

lots of misleading info on this out there, though, e.g. [https://github.com/ember-cli/ember-cli/issues/1352](https://github.com/ember-cli/ember-cli/issues/1352)
