Electron —— Cannot find module ‘jquery.min.js’

发布时间:2020-10-12 03:26:13 作者:tywali
来源:网络 阅读:446

在页面中使用如下代码引入jquery:

<script>
    window.$ = window.jQuery = require('node_modules/jquery/dist/jquery.min.js');
</script>

运行时报错:
Uncaught Error: Cannot find module 'node_modules/jquery/dist/jquery.min.js'
 
这个错误一看就是跟路径有关,项目中引入jquery的index.html页面与node_modules的关系如下:
Electron —— Cannot find module ‘jquery.min.js’
 
按道理index.html与node_modules在同一个目录下,上面代码的引入方式应该是可以的,可是事实上electron就是没有找到正确的node_modules目录。
 
在引入jquery的地方增加“./”,其中“.”表示当前目录,即代码改为如下:

<script>
    window.$ = window.jQuery = require('./node_modules/jquery/dist/jquery.min.js');
</script>
推荐阅读:
  1. 折腾Electron对JQuery的支持
  2. Electron —— Cannot find module ‘index.js’

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

electron cannot fin

上一篇:JavaScript对JSON数据进行排序和搜索

下一篇:python实现AES和RSA加解密的方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》