node.js 多 (webpack)-dev-server/client 中的错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42192339/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:00:15  来源:igfitidea点击:

ERROR in multi (webpack)-dev-server/client

node.jswebpackwebpack-dev-server

提问by Weijing Lin

I'm new to webpack / reactjs, just follow the tutorial here: https://www.tutorialspoint.com/reactjs/reactjs_environment_setup.htm

我是 webpack / reactjs 的新手,只需按照此处的教程进行操作:https://www.tutorialspoint.com/reactjs/reactjs_environment_setup.htm

Then after I 'npm start', I got error:

然后在我'npm start'之后,我得到了错误:

ERROR in multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js
Module not found: Error: Can't resolve 'babel' in '/var/www/jay/reactjs/react-app'
BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.
                 You need to specify 'babel-loader' instead of 'babel'.
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js

Any ideas?

有任何想法吗?

回答by Michael Jungo

The tutorial you are following uses Webpack 1, but you are now using Webpack 2 which has some breaking changes. The error tells you that you can no longer omit -loaderwhen specifying your loaders. All you need to do is replace

您正在学习的教程使用 Webpack 1,但您现在使用的是 Webpack 2,它有一些重大更改。该错误告诉您-loader在指定加载程序时不能再省略。您需要做的就是更换

loader: 'babel'

with

loader: 'babel-loader'

To see what else you might need to change, you can have a look at the migration guide from the official docs: https://webpack.js.org/guides/migrating/

要查看您可能需要更改的其他内容,您可以查看官方文档中的迁移指南:https: //webpack.js.org/guides/migrating/

回答by Samueltommzy

You might have to add babel-loader as part of your dev dependencies by runnning npm install --save-dev babel-loader. This adds babel-loaderto your package.jsonfile.

您可能需要通过运行将 babel-loader 添加为开发依赖项的一部分npm install --save-dev babel-loader。这会添加babel-loader到您的package.json文件中。

回答by Barbie

Error in angular dependencies. It may be with renaming files or folders in angular.json

角度依赖错误。它可能与重命名 angular.json 中的文件或文件夹有关