Search code examples
ember.jsember-cli

Import jquery with ember-cli


Since ember-cli 0.0.34 jquery is removed from the .jshint file as predefined. So jquery needs to be imported, but I get the following error when doing it:

import $ from 'jquery';

The error I get is:

ENOENT, no such file or directory 'S:\...\tmp\tree_merger-tmp_dest_dir-Nb27WzDk.tmp\jquery.js'
Error: ENOENT, no such file or directory 'S:\...\tmp\tree_merger-tmp_dest_dir-Nb27WzDk.tmp\jquery.js'
    at Object.fs.statSync (fs.js:684:18)
    at addModule (S:\...\node_modules\ember-cli\node_modules\broccoli-es6-concatenator\index.js:81:46)
    .....

Solution

  • I solved the problem by not importing jquery at all. jQuery is available via Ember.$ (link)

    So I changed my code to use Ember.$(...) instead of $(...)