ERROR in ./node_modules/jquery/lib/node-jquery.js Module not found: Error: Can't resolve 'jsdom'... ERROR in ./node_modules/jquery/lib/node-jquery.js Module not found: Error: Can't resolve 'xmlhttprequest'... ERROR in ./node_modules/jquery/lib/node-jquery.js Module not found: Error: Can't resolve 'LOCATIOn'... ERROR in ./node_modules/jquery/lib/node-jquery.js Module not found: Error: Can't resolve 'navigator'...
我很确定这是在搜索错误之后与webpack 2有关,但是所提出的解决方案都没有解决错误.
我见过但不起作用的一个解决方案是在我的webpack配置中添加以下内容:
plugins: [ new webpack.ProvidePlugin({ $: "jquery",jQuery: "jquery" }) ],
这是我的index.html:
<html> <head> <Meta charset="utf-8"> <title>title</title> </head> <body> <div id="fb-root"></div> <div id="app"></div> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css"> <script src="common.js"></script> <script src="bundle.js" type="text/javascript"></script> </body> </html>
这是我的webpack.config.js:
var webpack = require('webpack'); var path = require('path'); var BUILD_DIR = path.resolve(__dirname,'public'); var APP_DIR = path.resolve(__dirname,'src','js'); var node_dir = __dirname + '/node_modules'; var config = { entry: { app: APP_DIR + '/index.js',common: ["jquery"],},output: { path: BUILD_DIR,filename: 'bundle.js' },resolve: { // This is so that you don't have to write the file extension while imporTing it. // Instead of import HomeComponent from './HomeComponent.jsx' // you can do import HomeComponent from './HomeComponent' extensions: ['.js','.jsx','.json','*'],alias: { 'jquery': node_dir + '/jQuery/src/wrapper.js',externals: { jquery: 'jQuery' },plugins: [ new webpack.optimize.CommonsChunkPlugin({ name: "common",filename: "common.js",minChunks: Infinity,}),new webpack.ProvidePlugin({ $: "jquery",jQuery: "jquery",jquery: "jquery","window.jQuery": "jquery",],module: { loaders : [ { test : /\.jsx?/,include : APP_DIR,exclude: /node_modules/,loader : 'babel-loader' } ],}; module.exports = config;
这是错误:
以上是大佬教程为你收集整理的安装jQuery会导致webpack错误全部内容,希望文章能够帮你解决安装jQuery会导致webpack错误所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。