"找不到模块jquery"在电子应用中

时间:2017-06-29 02:30:36

标签: javascript jquery webpack vue.js electron

所以我收到错误"找不到模块jquery"在我的电子申请中。在我的index.ejs文件中,我有代码:

      window.jQuery = window.$ = require('jquery');

脚本标记内部。

1 个答案:

答案 0 :(得分:1)

您需要将jquery作为依赖关系添加到app/package.json

将目录更改为app并运行

npm i jquery --save

或者如果您正在使用纱线

yarn add jquery

之后看起来应该是这样的。

{
  "name": "vueelectron",
  "version": "0.0.0",
  "description": "An electron-vue project",
  "main": "./dist/main.js",
  "dependencies": {
    "babel-runtime": "^6.23.0",
    "bootstrap": "^3.3.7",
    "jquery": "^3.2.1",
    "vue": "^2.1.10",
    "vue-electron": "^1.0.6",
    "vue-resource": "^1.0.3",
    "vue-router": "^2.1.2",
    "vuex": "^2.3.1"
  },
  "devDependencies": {},
  "author": ""
}