【问题标题】:Adding NPM module to Ember app将 NPM 模块添加到 Ember 应用程序
【发布时间】:2016-04-03 08:26:46
【问题描述】:

我正在尝试在我的 Ember 应用程序中通过 ember-browserify 使用 bootbox。我已经像 npm 模块一样安装了 bootbox,并在代码旁边添加了:

import Bootbox from 'npm:bootbox';

使用 ember-cli 编译时出现错误:

The Broccoli Plugin: [object Object] failed with:
Error: Cannot find module 'jquery' from '/Users/Crabar/Documents/Programming/EmberDrinkIt/node_modules/bootbox'

版本:Ember 2.2.0、EmberCLI 2.4.3

【问题讨论】:

    标签: ember.js npm browserify


    【解决方案1】:

    您是否尝试过在 Brocfile.js 中导入节点模块?

    app.import('node_modules/<path_to_module>.js');
    

    【讨论】:

    • 我尝试添加 app.import('node_modules/bootbox.min.js');但没有任何改变。另外,我已经以类似的方式导入了另一个库(CryptoJS)并且它可以工作。
    • 似乎 app.import('node_modules/bootbox.min.js') 是一条不太可能的路径,更像是 node_modules/bootbox/bootbox.min.js。请再检查一次
    • 是的,你是对的。但新路径没有任何改变。
    • 实际上,我不明白您为什么会收到 jquery 错误。你在项目中安装了jquery吗?如果是这样,可能是 bootbox 需要特定版本的 jquery
    • 根据更新日志github.com/ember-cli/ember-cli/releases/tag/v2.3.0,我已在一周前从 bower.json 中删除了“jquery”。
    猜你喜欢
    • 2015-03-27
    • 2018-03-10
    • 1970-01-01
    • 2016-12-23
    • 1970-01-01
    • 1970-01-01
    • 2018-06-16
    • 1970-01-01
    • 2019-04-16
    相关资源
    最近更新 更多