2

我在用

"webpack": "^2.4.1",
"webpack-dev-middleware": "^1.10.2",
"react-hot-loader": "next",
"webpack-hot-middleware": "^2.18.0",

这是 webpack 客户端配置条目

entry: {
main: [
  'react-hot-loader/patch',
  'webpack-hot-middleware/client',
  './client.js',
],
vendor,

},

这是服务器/index.js

import webpackConfig from '../webpack/webpack.config.client';
const app = express();

const compiler = webpack(webpackConfig);

app.use(webpackDev(compiler, {
  noInfo: true,
  publicPath: webpackConfig.output.publicPath,
  serverSideRender: true,
}));

app.use(webpackHot(compiler));

现在当我运行服务器时npm run build:dev && babel-node -- dist/SSR.js

我收到此错误。

ERROR in multi react-hot-loader/patch webpack-hot-middleware/client ./client.js
Module not found: Error: Can't resolve './client.js' in '/app'
@ multi react-hot-loader/patch webpack-hot-middleware/client ./client.js

ERROR in multi react react-dom redux react-redux react-router-dom react-helmet axios
Module not found: Error: Can't resolve 'react' in '/app'
@ multi react react-dom redux react-redux react-router-dom react-helmet axios

ERROR in multi react react-dom redux react-redux react-router-dom react-helmet axios
Module not found: Error: Can't resolve 'react-dom' in '/app'
@ multi react react-dom redux react-redux react-router-dom react-helmet axios

ERROR in multi react react-dom redux react-redux react-router-dom react-helmet axios
Module not found: Error: Can't resolve 'redux' in '/app'
@ multi react react-dom redux react-redux react-router-dom react-helmet axios

为什么 Webpack Dev 中间件只尝试解析“/app”中的包。

感谢帮助。

4

0 回答 0