我正在使用 scrape-it模块:https://github.com/IonicaBizau/scrape-it
我试图用 webpack 捆绑我的js;但是,我得到了
ERROR in ./~/scrape-it/~/cheerio/index.js
Module not found: Error: Cannot resolve 'file' or 'directory' ./package in /Users/Spicycurryman/Desktop/Main/styell/node_modules/scrape-it/node_modules/cheerio
resolve file
完整堆栈跟踪:
ERROR in ./~/scrape-it/~/cheerio-req/~/cheerio/index.js
Module not found: Error: Cannot resolve 'file' or 'directory' ./package in /Users/Spicycurryman/Desktop/Main/styell/node_modules/scrape-it/node_modules/cheerio-req/node_modules/cheerio
resolve file
/Users/Spicycurryman/Desktop/Main/styell/node_modules/scrape-it/node_modules/cheerio-req/node_modules/cheerio/package doesn't exist
/Users/Spicycurryman/Desktop/Main/styell/node_modules/scrape-it/node_modules/cheerio-req/node_modules/cheerio/package.webpack.js doesn't exist
/Users/Spicycurryman/Desktop/Main/styell/node_modules/scrape-it/node_modules/cheerio-req/node_modules/cheerio/package.web.js doesn't exist
/Users/Spicycurryman/Desktop/Main/styell/node_modules/scrape-it/node_modules/cheerio-req/node_modules/cheerio/package.js doesn't exist
resolve directory
/Users/Spicycurryman/Desktop/Main/styell/node_modules/scrape-it/node_modules/cheerio-req/node_modules/cheerio/package doesn't exist (directory default file)
/Users/Spicycurryman/Desktop/Main/styell/node_modules/scrape-it/node_modules/cheerio-req/node_modules/cheerio/package/package.json doesn't exist (directory description file)
[/Users/Spicycurryman/Desktop/Main/styell/node_modules/scrape-it/node_modules/cheerio-req/node_modules/cheerio/package]
[/Users/Spicycurryman/Desktop/Main/styell/node_modules/scrape-it/node_modules/cheerio-req/node_modules/cheerio/package.webpack.js]
[/Users/Spicycurryman/Desktop/Main/styell/node_modules/scrape-it/node_modules/cheerio-req/node_modules/cheerio/package.web.js]
[/Users/Spicycurryman/Desktop/Main/styell/node_modules/scrape-it/node_modules/cheerio-req/node_modules/cheerio/package.js]
@ ./~/scrape-it/~/cheerio-req/~/cheerio/index.js 11:18-38
由于存在所有适当的模块,我对于为什么会发生这种情况感到困惑。 这是我的webpack.config.js文件,可能是问题的根源。
var webpack = require('webpack');
var path = require('path');
var fs = require('fs');
var request = require('request');
var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
module.exports = {
entry: "./main.js",
output: {
path: __dirname,
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.json$/, loader: 'json-loader' }
]
},
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.js']
},
node: {
console: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty'
}
}
为什么会这样?如何解决这个问题?
答案 0 :(得分:0)
想出来。
我必须将'.json'
添加到resolve.extensions。
我现在现在得到一个无关的错误:(
Using Webpack with Mongoose - mongoose.model is not a function