First, generate the shim:
ember generate vendor-shim moment
Next, provide the vendor asset path:
app.import('vendor/shims/moment.js');
Finally, use the package by adding the appropriate import statement:
import moment from 'moment';
// ...
var day = moment('Dec 25, 1995');
But throw error when run moment : `Uncaught (in promise) TypeError: (0 , _moment.default) is not a function(…)``
I using ember-cli 2.3.0
Just to confirm, are you importing moment before your shim?
The following seems to work
app.import('bower_components/moment/moment.js');
app.import('vendor/shims/moment.js');
The shim is a default vendor-shim blueprint generated file and moment is from bower. If you're dead keen on using npm I think you may be better off using ember-browserify.
Solved my problem @lpaluszk thanks :dancer:
I opened an RFC issue to discuss a more elegant solution for this: https://github.com/ember-cli/rfcs/issues/84
@runspired this is already supported via https://github.com/ember-cli/rfcs/pull/55 / https://github.com/ember-cli/ember-cli/pull/5976
assuming moment is amd:
app.import('bower_components/moment/moment.js', {
amdModule: 'moment'
})
Most helpful comment
assuming moment is
amd: