【发布时间】:2019-02-16 01:15:57
【问题描述】:
我想在任何地方使用 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
}
}
我试图找到一个解决方案,但没有任何帮助。我还转储了所有节点模块并再次运行 npn install,再次安装 cors-everwhere。
Afaik 这个“fs”和“net”是节点的基本部分吗?所以我有点困惑为什么他们应该在这里失踪......
如果有人有想法,那就太好了 - 谢谢!
最好的问候, 丹尼尔
【问题讨论】:
-
我有一个相关问题,但对我来说,我的构建工具似乎无法正常工作。当我
npm install或安装其他 npm 模块时,我在命令行中的 npm 中遇到了许多错误。删除 node_modules 目录后运行 npm install 时是否出现任何错误?
标签: javascript webpack cors backend cors-anywhere