打包webpack时出错:ERROR in ./node_modules/jquery/lib/node-jquery.js

打包webpack时出错:
ERROR in ./node_modules/jquery/lib/node-jquery.js

npm run dev

报错提示:

ERROR in ./node_modules/jquery/lib/node-jquery.js
Module not found: Error: Can't resolve 'jsdom' in 'E:\Users\Administrator\Desktop\webpack笔记\node_modules\jquery\lib'
 @ ./node_modules/jquery/lib/node-jquery.js 5:13-29
 @ ./src/index.js

ERROR in ./node_modules/jquery/lib/node-jquery.js
Module not found: Error: Can't resolve 'location' in 'E:\Users\Administrator\Desktop\webpack笔记\node_modules\jquery\lib'
 @ ./node_modules/jquery/lib/node-jquery.js 13:24-43
 @ ./src/index.js

ERROR in ./node_modules/jquery/lib/node-jquery.js
Module not found: Error: Can't resolve 'navigator' in 'E:\Users\Administrator\Desktop\webpack笔记\node_modules\jquery\lib'
 @ ./node_modules/jquery/lib/node-jquery.js 17:25-45
 @ ./src/index.js

ERROR in ./node_modules/jquery/lib/node-jquery.js
Module not found: Error: Can't resolve 'xmlhttprequest' in 'E:\Users\Administrator\Desktop\webpack笔记\node_modules\jquery\lib'
 @ ./node_modules/jquery/lib/node-jquery.js 8:28-53
 @ ./src/index.js
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! module-webpack@1.0.0 dev: `webpack`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the module-webpack@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2020-05-13T16_12_47_307Z-debug.log

解决:

  1. 查看默认打包入口index.js是否在src文件夹中,(该src文件夹包含index.html及index.js)

  2. 在项目目录终端安装jQuery时,输入命令: npm install jquery -S ,注意此时要安装jquery,而不是jQuery,不然同样会报错

打包成功的结果:
在这里插入图片描述

  • 14
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值