我想在任何地方使用cors-anywhere,但是我得到了这个错误:
ERROR in ./~/cors-anywhere/lib/cors-anywhere.js
Module not found: Error: Cannot resolve module 'net' in /Users/<username>/<project>/node_modules/cors-anywhere/lib
@ ./~/cors-anywhere/lib/cors-anywhere.js 7:10-24
ERROR in ./~/cors-anywhere/lib/cors-anywhere.js
Module not found: Error: Cannot resolve module 'fs' in /<username>/<project>/node_modules/cors-anywhere/lib
@ ./~/cors-anywhere/lib/cors-anywhere.js 20:4-17我是通过
npm install cors-everywhere我还将其添加到package.json中:
"cors-anywhere": "^0.4.0"这是我的webpack.config:
module.exports = {
entry: ['babel-polyfill', './app/index.js'],
output: {
path: './build',
// if the above line does not work, try `path: __dirname + '/build'`
filename: 'bundle.js',
target: 'node'
},
module: {
loaders: [
{
test: /\.js$/, // a regular expression that catches .js files
exclude: /node_modules/,
loader: 'babel-loader'
}
]
},
devServer: {
port: 3000, // most common port
contentBase: './build',
inline: true
}
}我试着找到一个解决方案,但没有什么真正有帮助的。我还转储了所有的node-module,并再次运行npn install,再一次安装cors。
Afaik这个"fs“和"net”是node的基本部分吗?所以我有点搞不懂为什么他们会在这里消失...
如果有人有主意的话就太好了--谢谢!
致以最好的问候,丹尼尔
发布于 2017-05-10 19:47:54
target属性未正确放置,应将其放置在对象根目录中,而不是output中
entry: ['babel-polyfill', './app/index.js'],
output: {
path: './build',
// if the above line does not work, try `path: __dirname + '/build'`
filename: 'bundle.js',
},
target: 'node',
...https://stackoverflow.com/questions/43891413
复制相似问题