简体   繁体   中英

Installing dygraphs with bower install fails on Ember.js

Issuing a statement:

bower install dygraphs --save

And than adding reference to dygraphs:

app.import('vendor/dygraphs/src/dygraph.js')

Causes an error:

Uncaught SyntaxError: Unexpected identifier

on line:

import DygraphLayout from './dygraph-layout';

And:

Uncaught ReferenceError: define is not defined at ember-adater-file .js:1

What can be the cause of this and how to fix it?

You are trying to app.import an ES6 module, which is not supported.

Since Ember is discouraging the use of bower, you can try installing dygraphs through npm

npm install --save-dev dygraphs

And use ember-browserify to import it.

npm install --save-dev ember-browserify

Then in your code you can do

import Dygraph from "npm:dygraph";

And use it right away in your component.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM