Emberjs:'npm install'之后如何导入

时间:2018-04-29 04:41:51

标签: ember.js npm-install

尝试在Controller中使用howler.js(An instance profile can only include one role)。

Howler没有插件,但它作为npm包存在。

我做了一个npm install,随后在package.json中得到了更新,如下所示:

"dependencies": { "bootswatch": "^4.0.0", "howler": "^2.0.9", "npm": "^5.8.0" }

在控制器中我添加了此导入

import {Howl} from 'howler';

但是当我尝试执行代码时,我收到运行时错误

Could not find module 'howler' imported from 'foo/controllers/bar'

当我为find执行*howl*时,这就是我找到的

./node_modules/howler/dist/howler.js ./node_modules/howler/dist/howler.core.min.js ./node_modules/howler/dist/howler.min.js ./node_modules/howler/dist/howler.spatial.min.js ./node_modules/howler/src/howler.core.js ./node_modules/howler/src/plugins/howler.spatial.js

我的导入是否应该将这些文件作为其中一部分的路径?如果是哪一个?

对于我在那里所做的事情是否存在明显错误的一些建议表示赞赏。

Emberjs版本是3.0。

由于

1 个答案:

答案 0 :(得分:3)

您可以像这样导入howler.js内的ember-cli-build.js

app.import('node_modules/howler/dist/howler.min.js')

然后你可以在你的ember app中使用Howl作为全局变量。