How to use third party npm packages with ember cli app

Preexo

EDIT: this is actually about any npm package which is not designed to play along with ember. In my case, I tried to make crypto-js work, but it seems to be always the same trouble with any npm package not specially designed for ember cli.

I want to use cryptoJS in my ember app, which I'm currently refactoring with ember cli, but I'm having a lot of trouble importing all the third party packages and libraries I'm already using, like for example cryptoJS.

CryptoJS at least has a package for npm, I don't even want to think about what happens if some of my included libraries don't have a package...

Am I just missing the point in the documentation of ember-cli or is it really not described how to import other npm packages and also how to inlcude non-package libraries properly to keep them under version control and dependency control?

If I follow the description of the crypto-js package manual:

var CryptoJS = require("crypto-js");
console.log(CryptoJS.HmacSHA1("Message", "Key"));

I get and error in my ember build

utils/customauthorizer.js: line 1, col 16, 'require' is not defined.

Thanks for any help on this, I'm very excited about the ember cli project, but importing my existing ember app has been quite painful so far...

EDIT:

Just importing unfortunately does not work.

import CryptoJS from 'crypto-js';

throws during the build

daily@dev1:~/VMD$ ember build
version: 0.1.2
Build failed.
File: vmd/utils/customauthorizer.js
ENOENT, no such file or directory '/home/daily/VMD/tmp/tree_merger-tmp_dest_dir-F7mfDQyP.tmp/crypto-js.js'
Error: ENOENT, no such file or directory '/home/daily/VMD/tmp/tree_merger-tmp_dest_dir-F7mfDQyP.tmp/crypto-js.js'
    at Error (native)
    at Object.fs.statSync (fs.js:721:18)
    at addModule (/home/daily/VMD/node_modules/ember-cli/node_modules/broccoli-es6-concatenator/index.js:84:46)
    at addModule (/home/daily/VMD/node_modules/ember-cli/node_modules/broccoli-es6-concatenator/index.js:133:9)
    at addModule (/home/daily/VMD/node_modules/ember-cli/node_modules/broccoli-es6-concatenator/index.js:133:9)
    at /home/daily/VMD/node_modules/ember-cli/node_modules/broccoli-es6-concatenator/index.js:59:7
    at $$$internal$$tryCatch (/home/daily/VMD/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:470:16)
    at $$$internal$$invokeCallback (/home/daily/VMD/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:482:17)
    at $$$internal$$publish (/home/daily/VMD/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:453:11)
    at $$rsvp$asap$$flush (/home/daily/VMD/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:1531:9)
Timm

The easiest and recommended answer is to use ember-browserify. (as support for bower packages will be removed in the future.)

This is an example for using the npm package dexie within an Ember CLI app.

Install browserify: npm install ember-browserify --save-dev

Install dexie (or whatever module you need): npm install dexie --save-dev

Import the module like this: import Dexie from 'npm:dexie';

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to use third party javascript from ember-cli route

From Dev

How to use third party extension in react app?

From Dev

How to use django-contact-form (third-party app)?

From Dev

How to use django-contact-form (third-party app)?

From Dev

How to reference a third party npm module?

From Dev

How to add fields to third party app model?

From Dev

How to switch/transition an Ember route from third party library?

From Dev

How to use third party package in Laravel?

From Java

How to use third party libraries with Scala REPL?

From Dev

How to use a third-party library in a taskKey?

From Dev

How to use third party library in Python?

From Dev

How to add a third party library when using angular-cli?

From Dev

Proper way to access third party libs such as D3 in Ember CLI?

From Dev

Use EmberScript in Ember-CLI app

From Dev

Use EmberScript in Ember-CLI app

From Dev

How to replace the handlebars with htmlbars in Ember CLI app?

From Dev

How to deploy an Ember CLI app to Azure Websites

From Dev

How to replace the handlebars with htmlbars in Ember CLI app?

From Dev

How to install third party modules and libraries through flask web app

From Dev

How to install third party modules and libraries through flask web app

From Dev

Bash: How to determine whether terminal is opened by third-party app

From Dev

How to know which third party affects my app size?

From Dev

Resolving bean conflicts in third-party packages

From Dev

Understanding Risk for Upgrading Debian with Third Party Packages

From Dev

Resolving bean conflicts in third-party packages

From Dev

How to add third party java jars for use in pyspark

From Dev

How to add third-party Java JAR files for use in PySpark

From Dev

How can I use a third party Class Object as Hashmap Key?

From Dev

How to use third-party javascript library (pixijs) in ionic 2?

Related Related

  1. 1

    how to use third party javascript from ember-cli route

  2. 2

    How to use third party extension in react app?

  3. 3

    How to use django-contact-form (third-party app)?

  4. 4

    How to use django-contact-form (third-party app)?

  5. 5

    How to reference a third party npm module?

  6. 6

    How to add fields to third party app model?

  7. 7

    How to switch/transition an Ember route from third party library?

  8. 8

    How to use third party package in Laravel?

  9. 9

    How to use third party libraries with Scala REPL?

  10. 10

    How to use a third-party library in a taskKey?

  11. 11

    How to use third party library in Python?

  12. 12

    How to add a third party library when using angular-cli?

  13. 13

    Proper way to access third party libs such as D3 in Ember CLI?

  14. 14

    Use EmberScript in Ember-CLI app

  15. 15

    Use EmberScript in Ember-CLI app

  16. 16

    How to replace the handlebars with htmlbars in Ember CLI app?

  17. 17

    How to deploy an Ember CLI app to Azure Websites

  18. 18

    How to replace the handlebars with htmlbars in Ember CLI app?

  19. 19

    How to install third party modules and libraries through flask web app

  20. 20

    How to install third party modules and libraries through flask web app

  21. 21

    Bash: How to determine whether terminal is opened by third-party app

  22. 22

    How to know which third party affects my app size?

  23. 23

    Resolving bean conflicts in third-party packages

  24. 24

    Understanding Risk for Upgrading Debian with Third Party Packages

  25. 25

    Resolving bean conflicts in third-party packages

  26. 26

    How to add third party java jars for use in pyspark

  27. 27

    How to add third-party Java JAR files for use in PySpark

  28. 28

    How can I use a third party Class Object as Hashmap Key?

  29. 29

    How to use third-party javascript library (pixijs) in ionic 2?

HotTag

Archive