Getting "ReferenceError: jQuery is not defined" for package install on npm

Getting "ReferenceError: jQuery is not defined" for package install on npm

我已经发布了一个 jRCarousel jQuery 插件到 npm。我最初收到名称不能包含大写字母的错误,所以我在 package.json 中更改了它,然后发布它已发布但是在 npm 网站上,当我尝试 "Try it out" 选项时,我得到 "ReferenceError: jQuery is not defined" 错误。不确定为什么会出现错误,因为我在 package.json.

中指定了依赖项

此外,如果仅 package.json 而不是包或模块中的任何其他文件有任何更改,我如何才能仅更新 npm 上的 package.json 文件,或者我是否必须发布它是新版本号(我想避免)。

这是我的 package.json

{
  "name": "jrcarousel",
  "version": "1.0.0",
  "description": "jRCarousel - jQuery Responsive Carousel,
                  a modern, lightweight responsive carousel plugin",
  "main": "dist/jRCarousel.min.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/vinayakjadhav/jRCarousel.git"
  },
  "keywords": [
    "jquery-plugin",
    "ecosystem:jquery",
    "jQuery Resposive Carousel",
    "jQuery slider",
    "Responsive Slider",
    "Carousel",
    "Slider",
    "Gallery",
    "lightweight"
  ],
  "author": "Vinayak Rangnathrao Jadhav",
  "license": "MIT",
  "dependencies": {
    "jquery": "^1.9.1"
  },
  "bugs": {
    "url": "https://github.com/vinayakjadhav/jRCarousel/issues"
  },
  "homepage": "https://github.com/vinayakjadhav/jRCarousel",
  "devDependencies": {}
}

npm package

Github Repository

TRY IT OUT Link

注意:我是 npm 的新手,搜索了很多但与 jquery-插件发布相关的可用信息很少。感谢任何帮助。

用这段代码包装你的插件。 UMD 模式允许您的插件 运行 在浏览器和大多数模块捆绑器中。

(function (root, factory) {
    if (typeof define === "function" && define.amd) {
        define(["jquery"], factory);
    } else if (typeof exports === "object") {
        module.exports = factory(require("jquery"));
    } else {
        factory(root.jQuery);
    }
}(this, function ($) { 
    ...your plugin code goes here...
}));