Emberjs:如何在“npm install"后导入 [英] Emberjs : how to import after 'npm install'
问题描述
尝试使用 howler.js (https://github.com/goldfire/howler.js#documentation) 在控制器中.
Trying to use howler.js (https://github.com/goldfire/howler.js#documentation) in a Controller.
Howler 没有插件,但它作为 npm 包存在.
There is no addon for Howler but it exists as a npm package.
我做了一个 npm install
,随后在 package.json 中得到了如下更新:
I did an npm install
and subsequently got an update in package.json like this :
<代码>依赖关系":{"bootswatch": "^4.0.0","吼声": "^2.0.9","npm": "^5.8.0"}
在控制器中我添加了这个导入
In the controller I added this import
从 'howler' 导入 {Howl};
但是当我尝试执行代码时出现运行时错误
But when I try to execute the code I get a runtime error
找不到从foo/controllers/bar"导入的模块howler"
当我为 *howl*
做一个 find
这就是我找到的
When I do a find
for *howl*
this is what I find
<代码>./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
我的导入是否应该包含这些文件的路径作为其中的一部分?如果是,是哪一个?
Should my import have a path to these files as part of it ? If so which one ?
希望得到一些关于我在那里所做的事情是否有明显错误的建议.
Would appreciate some advice about whether there's something obviously wrong in what I've done there.
Emberjs 版本是 3.0.
Emberjs version is 3.0.
谢谢
推荐答案
您可以像这样在 ember-cli-build.js
中导入 howler.js
You can import the howler.js
inside your ember-cli-build.js
like this
app.import('node_modules/howler/dist/howler.min.js')
然后你可以在你的 ember 应用程序中使用 Howl
作为全局变量.
Then you can use Howl
as global variable inside you ember app.
这篇关于Emberjs:如何在“npm install"后导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!