Jquery TypeError:$不是函数-toastr.js-AMD和SystemJS

Jquery TypeError:$不是函数-toastr.js-AMD和SystemJS,jquery,aurelia,systemjs,amd,Jquery,Aurelia,Systemjs,Amd,我得到以下错误 toastr.js:60 Uncaught (in promise) TypeError: $ is not a function at getContainer (toastr.js:60) at notify (toastr.js:215) at r.error (toastr.js:49) 但是JQuery已经加载,所以我不知道发生了什么。 更新 我开始明白发生了什么 我在我的文件夹中本地编辑了以下文件:project/jspm\u package

我得到以下错误

toastr.js:60 Uncaught (in promise) TypeError: $ is not a function
    at getContainer (toastr.js:60)
    at notify (toastr.js:215)
    at r.error (toastr.js:49)
但是JQuery已经加载,所以我不知道发生了什么。

更新 我开始明白发生了什么

我在我的文件夹中本地编辑了以下文件:
project/jspm\u packages\npm\toastr@2.1.2\toastr.js

特别是在第470行附近:

我对旧代码进行了注释,并添加了以下内容:

}(typeof define === 'function' && define.amd ? define : function (deps, factory) {

    /*if (typeof module !== 'undefined' && module.exports) { //Node
        module.exports = factory(require('jquery'));
    } else {
        window.toastr = factory(window.jQuery);
    }*/

    window.toastr = factory(window.jQuery);
    module.exports = factory(window.jQuery);

}));
我感觉,
require('jquery')
命令导致了对位于
dist/jquery.js的文件的get请求

但是,此文件不存在,因此同事创建了一个空文件。 这修复了其他错误,但toastr似乎受到了影响。 我不是JS专家,但似乎
require
函数可能正在创建jquery的本地范围版本(基于
dist/JS
文件),然后将此引用传递给toastr的构造函数/工厂

问题 我的问题是toastr中的require正在dist中查找一个不存在的jquery文件。有没有办法创建一个包装文件,以预期的格式返回现有的JQuery

我认为包装器需要采用AMD格式…

package.json内容 config.js内容

解决方案 我找到了答案并贴了出来。我只需将jquery作为jquery安装(在项目中):


问题是toastr使用的是以下命令,即希望安装模块

     `module.exports = factory(require('jquery'));`
结果证明我所需要的只是跑步:

jspm安装jquery=jquery

参考资料:


在哪里加载的?它是否在无冲突模式下运行?复制错误的最少代码?你能分享代码吗?@Rohit.007这个项目非常庞大。我知道,在全局上下文中,$是JQuery,并且工作正常。然而,在toastr。。。它坏了。@Rohit.007@BenM@Santiago Trejo>我已经更新了描述。我的问题是toastr中的
require
正在dist中查找一个不存在的jquery文件。有没有办法创建一个包装文件,以预期的格式返回现有的JQuery?我想您需要尝试为JQuery模块安装NPM。
jspm install jquery=jquery
     `module.exports = factory(require('jquery'));`