jQuery error when webpack is running
Error message:
ERROR in ./node_modules/jQuery/lib/node-jquery.js 5:13-35
Module not found: Error: Can't resolve 'jsdom' in 'C:\Users\Dell\Desktop\dmeo\node_modules\jQuery\lib'
@ ./src/index.js 1:0-22 3:0-1 4:4-5 5:4-5
ERROR in ./node_modules/jQuery/lib/node-jquery.js 8:28-68
Module not found: Error: Can't resolve 'xmlhttprequest' in 'C:\Users\Dell\Desktop\dmeo\node_modules\jQuery\lib'
@ ./src/index.js 1:0-22 3:0-1 4:4-5 5:4-5
ERROR in ./node_modules/jQuery/lib/node-jquery.js 13:24-43
Module not found: Error: Can't resolve 'location' in 'C:\Users\Dell\Desktop\dmeo\node_modules\jQuery\lib'
@ ./src/index.js 1:0-22 3:0-1 4:4-5 5:4-5
Module not found: Error: Can't resolve 'navigator' in 'C:\Users\Dell\Desktop\dmeo\node_modules\jQuery\lib'
@ ./src/index.js 1:0-22 3:0-1 4:4-5 5:4-5
4 errors have detailed information that is not shown.
wrong reason:
The command to install the jquery package at that time was npm i jQuery -S
, this is indeed jQuery, after using npm run dev
the command to execute webpack, the corresponding style code can also be implemented, but an error will be reported.
Solution:
Uninstall the jQuery package we installed before npm uninstall jQuery -S
and then install jquery, npm i jquery -S
, it can be solved, and it will not report an error if you run it again
tips:
When we use jquery, the installation package installs jquery and does not install jQuery