简体   繁体   English

安装响应时出现Webpack错误。(当我尝试使用“ npm start”启动服务器时)

[英]Webpack error when i install react.(when i try to use “npm start” to start a sever)

it's the log of the error. 这是错误的日志。

when i try to start a sever by use "npm start",it give me this. 当我尝试使用“ npm start”启动服务器时,请给我这个。 My configuration is below . 我的配置如下。

    var config = {
  entry: './main.js',

  output: {
    path: '/C:\Users\34337\reactApp',
    filename: 'index.js',
  },

  devServer: {
    inline: true,
    port: 7777
  },

  module: {
    loaders: [{
      test: /\.jsx?$/,
      exclude: /node_modules/,
      loader: 'babel',

      query: {
        presets: ['es2015', 'react']
      }
    }]
  }
};
module.exports = config;

after i replace "loders" to "rules",it shows that i didn't set 'mode' option. 在将“ loders”替换为“ rules”之后,它表明我没有设置“ mode”选项。 the error after that. 之后的错误。

You need to check of babel-cli and babel-loader installed in your env, if not installed, run command: npm install --save babel-cli babel-loader babel-preset-es2015 babel-preset-react then rerun your starting script. 您需要检查环境中安装的babel-clibabel-loader ,如果未安装,请运行命令: npm install --save babel-cli babel-loader babel-preset-es2015 babel-preset-react然后重新运行启动脚本。

And configuration module point should looks like this: 并且配置module点应如下所示:

module: {
 rules: [
   {
     test: /\.js$/,
     exclude: /node_modules/,
     use: 'babel-loader',
     query: {
       presets: ['es2015', 'react']
     }
   }
 ]
}

For now you can ignore mode warning. 目前,您可以忽略mode警告。 Pay attention of my module config, and set babel-loader instead of babel . 注意我的module配置,并设置babel-loader而不是babel

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我尝试使用npm start命令运行React App时出错 - Error when I try run a React App with npm start command 在 React 项目中,当我尝试使用 npm 启动命令时出现错误 - In react project when i try to use npm start command getting error 当我编写 npm start 并收到此错误时,我的反应应用程序没有启动,任何人都可以帮助我,我是新来的反应。 我正在使用 Acode(Editor) 和 termux - My react app does not start when I write npm start and get this error can anyone please help me I am new to react. I am using Acode(Editor) and termux webpack和babel使用“ npm start”时反应错误 - webpack & babel Error for react when use 'npm start' 我无法在 React 中对我的项目执行“npm install”。 当我运行“npm install”时出现错误信息 - I can not do "npm install" to my project in React. When I running "npm install" i get error massage 当我使用“npm start”启动 React 应用程序时出错 - Error when I start React Application with “npm start” React App:为什么当我尝试运行 npm start 脚本时出现错误? - React App: Why I get an error when I try to run npm start script? 当我在 cmd 中使用 npm start 启动我的反应应用程序时,我收到以下错误 - when I use npm start in cmd to start my react app iam getting the following error 当我尝试开始响应时,为什么会出现此错误? - Why am I getting this error when I try to start react? 当我运行npm start命令运行React应用程序时出错! - Error!when i ran npm start command for running react application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM