我现在安装了jQuery,现在看到了一堆Module not found: Error: Can't resolve...错误.知道根本问题可能是什么和解决方案?
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'...Run Code Online (Sandbox Code Playgroud)
我很确定这是在搜索错误之后与webpack 2有关,但是所提出的解决方案都没有解决错误.
我见过但不起作用的一个解决方案是在我的webpack配置中添加以下内容:
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
],Run Code Online (Sandbox Code Playgroud)
这是我的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" …Run Code Online (Sandbox Code Playgroud)