webpack常见调试问题

时间:2024-03-26 21:50:29

webpack打包常见问题

问题一:
peerDependencies WARNING [email protected]* requires a peer of [email protected]^4.0.0 || ^5.0.0 but [email protected] was installed
peerDependencies WARNING [email protected][email protected]^3.7.2 requires a peer of [email protected]^4.0.0 but [email protected] was installedwebpack常见调试问题
提示安装这个工具,或包的,需要的对应的其他包的版本,此例子中已经安装的webpack3.8.1 需要升级为4.0.0版本或5.0.0版本。
问题二

webpack常见调试问题
提示我们安装 webpack-li
问题三
ERROR in multi ./src/main.js ./dist/bundle.js
Module not found: Error: Can’t resolve ‘./dist/bundle.js’ in ‘D:\VS Code\work\WEBPACK-STUDY’
webpack常见调试问题
原因,因为版本不同,打包的指令也有所不同,有的版本直接
webpack 要打包文件 生成的打包文件 例如: webpack ./src/main.js ./dist/bundle.js
有的版本 webpack 要打包文件 -o 生成的打包文件 例如:webpack ./src/main.js -o ./dist/bundle.js

问题四
webpack常见调试问题

ERROR in ./node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js
Module not found: Error: Can’t resolve ‘child_process’ in ‘D:\VS Code\work\WEBPACK-STUDY\node_modules\jsdom\lib\jsdom\living\xhr’
@ ./node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js 4:22-46
@ ./node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequest.js
@ ./node_modules/jsdom/lib/jsdom/living/interfaces.js
@ ./node_modules/jsdom/lib/jsdom/browser/Window.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/jquery/node-jquery.js
@ ./src/main.js

ERROR in ./node_modules/jsdom/lib/api.js
Module not found: Error: Can’t resolve ‘fs’ in ‘D:\VS Code\work\WEBPACK-STUDY\node_modules\jsdom\lib’
@ ./node_modules/jsdom/lib/api.js 3:11-24
@ ./node_modules/jquery/node-jquery.js
@ ./src/main.js

ERROR in ./node_modules/jsdom/lib/jsdom/browser/resources/resource-loader.js
Module not found: Error: Can’t resolve ‘fs’ in ‘D:\VS Code\work\WEBPACK-STUDY\node_modules\jsdom\lib\jsdom\browser\resources’
@ ./node_modules/jsdom/lib/jsdom/browser/resources/resource-loader.js 2:11-24
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/jquery/node-jquery.js
@ ./src/main.js

ERROR in ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js
Module not found: Error: Can’t resolve ‘fs’ in ‘D:\VS Code\work\WEBPACK-STUDY\node_modules\jsdom\lib\jsdom\living\xhr’
@ ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js 2:11-24
@ ./node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js
@ ./node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequest.js
@ ./node_modules/jsdom/lib/jsdom/living/interfaces.js
@ ./node_modules/jsdom/lib/jsdom/browser/Window.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/jquery/node-jquery.js
@ ./src/main.js

ERROR in ./node_modules/request/lib/har.js
Module not found: Error: Can’t resolve ‘fs’ in ‘D:\VS Code\work\WEBPACK-STUDY\node_modules\request\lib’
@ ./node_modules/request/lib/har.js 3:9-22
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/jsdom/lib/jsdom/living/helpers/wrap-cookie-jar-for-request.js
@ ./node_modules/jsdom/lib/jsdom/browser/resources/resource-loader.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/jquery/node-jquery.js
@ ./src/main.js

ERROR in ./node_modules/jquery/node-jquery.js
Module not found: Error: Can’t resolve ‘location’ in ‘D:\VS Code\work\WEBPACK-STUDY\node_modules\jquery’ @ ./node_modules/jquery/node-jquery.js 6:32-51
@ ./src/main.js

ERROR in ./node_modules/jquery/node-jquery.js
Module not found: Error: Can’t resolve ‘navigator’ in ‘D:\VS Code\work\WEBPACK-STUDY\node_modules\jquery’
@ ./node_modules/jquery/node-jquery.js 7:34-54
@ ./src/main.js

ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can’t resolve ‘net’ in ‘D:\VS Code\work\WEBPACK-STUDY\node_modules\forever-agent’
@ ./node_modules/forever-agent/index.js 6:10-24
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/jsdom/lib/jsdom/living/helpers/wrap-cookie-jar-for-request.js
@ ./node_modules/jsdom/lib/jsdom/browser/resources/resource-loader.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/jquery/node-jquery.js
@ ./src/main.js

ERROR in ./node_modules/request-promise-native/node_modules/tough-cookie/lib/cookie.js
Module not found: Error: Can’t resolve ‘net’ in ‘D:\VS Code\work\WEBPACK-STUDY\node_modules\request-promise-native\node_modules\tough-cookie\lib’
@ ./node_modules/request-promise-native/node_modules/tough-cookie/lib/cookie.js 32:10-24
@ ./node_modules/request-promise-native/lib/rp.js
@ ./node_modules/jsdom/lib/jsdom/browser/resources/resource-loader.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/jquery/node-jquery.js
@ ./src/main.js

ERROR in ./node_modules/request/node_modules/tough-cookie/lib/cookie.js
Module not found: Error: Can’t resolve ‘net’ in ‘D:\VS Code\work\WEBPACK-STUDY\node_modules\request\node_modules\tough-cookie\lib’
@ ./node_modules/request/node_modules/tough-cookie/lib/cookie.js 32:10-24
@ ./node_modules/request/lib/cookies.js
@ ./node_modules/request/index.js
@ ./node_modules/jsdom/lib/jsdom/living/helpers/wrap-cookie-jar-for-request.js
@ ./node_modules/jsdom/lib/jsdom/browser/resources/resource-loader.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/jquery/node-jquery.js
@ ./src/main.js

ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can’t resolve ‘net’ in ‘D:\VS Code\work\WEBPACK-STUDY\node_modules\tunnel-agent’
@ ./node_modules/tunnel-agent/index.js 3:10-24
@ ./node_modules/request/lib/tunnel.js
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/jsdom/lib/jsdom/living/helpers/wrap-cookie-jar-for-request.js
@ ./node_modules/jsdom/lib/jsdom/browser/resources/resource-loader.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/jquery/node-jquery.js
@ ./src/main.js

ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can’t resolve ‘tls’ in ‘D:\VS Code\work\WEBPACK-STUDY\node_modules\forever-agent’
@ ./node_modules/forever-agent/index.js 7:10-24
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/jsdom/lib/jsdom/living/helpers/wrap-cookie-jar-for-request.js
@ ./node_modules/jsdom/lib/jsdom/browser/resources/resource-loader.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/jquery/node-jquery.js
@ ./src/main.js

ERROR in ./node_modules/tunnel-agent/index.js

@ ./node_modules/tunnel-agent/index.js 4:10-24
@ ./node_modules/request/lib/tunnel.js
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/jsdom/lib/jsdom/living/helpers/wrap-cookie-jar-for-request.js
@ ./node_modules/jsdom/lib/jsdom/browser/resources/resource-loader.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/jquery/node-jquery.js
@ ./src/main.js

ERROR in ./node_modules/jquery/node-jquery.js
Module not found: Error: Can’t resolve ‘xmlhttprequest’ in ‘D:\VS Code\work\WEBPACK-STUDY\node_modules\jquery’
@ ./node_modules/jquery/node-jquery.js 10:28-53
@ ./src/main.js

我的问题是jquery的安装的版本,改了低版本的jquery 就解决了
npm install [email protected] -D

菜狗的成长之路。加油!!!