Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Webpack/babel加载器在新项目中产生许多错误_Reactjs_Webpack_Babeljs_React Jsx - Fatal编程技术网

Reactjs Webpack/babel加载器在新项目中产生许多错误

Reactjs Webpack/babel加载器在新项目中产生许多错误,reactjs,webpack,babeljs,react-jsx,Reactjs,Webpack,Babeljs,React Jsx,我有一个.jsx文件,在一个项目的webpack构建过程中不会产生错误。当我把它放到另一个项目中,使用不同的webpack配置时,它现在会产生大量的错误,其中大多数看起来像是挑剔的语法错误,不应该影响文件是否能够正确运行 有人知道为什么第二个项目会对同一个文件产生如此多的错误吗?我需要在webpack配置或babel依赖项中调整什么,以避免webpack为缩进等语法相关项产生如此多的错误,以及我是否使用var vs let 以下是一些错误的示例: 1:0 error Unexpe

我有一个.jsx文件,在一个项目的webpack构建过程中不会产生错误。当我把它放到另一个项目中,使用不同的webpack配置时,它现在会产生大量的错误,其中大多数看起来像是挑剔的语法错误,不应该影响文件是否能够正确运行

有人知道为什么第二个项目会对同一个文件产生如此多的错误吗?我需要在webpack配置或babel依赖项中调整什么,以避免webpack为缩进等语法相关项产生如此多的错误,以及我是否使用var vs let

以下是一些错误的示例:

    1:0    error  Unexpected var, use let or const instead                         no-var
    2:0    error  Unexpected var, use let or const instead                         no-var
    3:0    error  Unexpected var, use let or const instead                         no-var
    4:0    error  Unexpected var, use let or const instead                         no-var
    4:4    error  LayoutStyles is defined but never used                           no-unused-vars
    5:0    error  Unexpected var, use let or const instead                         no-var
    6:0    error  Unexpected var, use let or const instead                         no-var
    6:4    error  LayoutSizes is defined but never used                            no-unused-vars
    7:0    error  Unexpected var, use let or const instead                         no-var
    8:0    error  Unexpected var, use let or const instead                         no-var
   10:0    error  Unexpected var, use let or const instead                         no-var
   16:21   error  Missing function expression name                                 func-names
   17:6    error  Expected indentation of 6 characters                             indent
   20:24   error  Missing function expression name                                 func-names
   20:34   error  Missing space before opening brace                               space-before-blocks
   23:12   error  Missing function expression name                                 func-names
   24:6    error  Expected indentation of 6 characters                             indent
   24:8    error  Unexpected var, use let or const instead                         no-var
   26:6    error  Expected indentation of 6 characters                             indent
   26:8    error  Unexpected var, use let or const instead                         no-var
   27:12   error  Missing parentheses around multilines JSX                        react/wrap-multilines
   27:59   error  "optionStyle" used outside of binding context                    block-scoped-var
   27:59   error  optionStyle was used before it was defined                       no-use-before-define
   27:85   error  Missing function expression name                                 func-names
   27:95   error  Missing space before opening brace                               space-before-blocks
   27:118  error  Missing semicolon                                                semi
   30:6    error  Expected indentation of 6 characters                             indent
   30:8    error  Keyword "if" must be followed by whitespace                      space-after-keywords
   30:27   error  Expected '===' and instead saw '=='                              eqeqeq
   30:41   error  Missing space before opening brace                               space-before-blocks
   31:8    error  Expected indentation of 8 characters                             indent
   32:16   error  Missing parentheses around multilines JSX                        react/wrap-multilines
   32:62   error  "optionSelectedStyle" used outside of binding context            block-scoped-var
   33:33   error  "selectedPinkStyle" used outside of binding context              block-scoped-var
   35:6    error  Expected indentation of 6 characters                             indent
   37:6    error  Expected indentation of 6 characters                             indent
   37:8    error  Unexpected var, use let or const instead                         no-var
   37:8    error  All "var" declarations must be at the top of the function scope  vars-on-top
   37:26   error  Trailing spaces not allowed                                      no-trailing-spaces
   38:12   error  Missing parentheses around multilines JSX                        react/wrap-multilines
   38:72   error  optionStyle was used before it was defined                       no-use-before-define
   38:72   error  "optionStyle" used outside of binding context                    block-scoped-var
   38:98   error  Missing function expression name                                 func-names
   38:108  error  Missing space before opening brace                               space-before-blocks
   38:128  error  Missing semicolon                                                semi
   40:29   error  Missing semicolon                                                semi
   41:6    error  Expected indentation of 6 characters                             indent
   41:8    error  Keyword "if" must be followed by whitespace                      space-after-keywords
   41:27   error  Expected '===' and instead saw '=='                              eqeqeq
   41:38   error  Missing space before opening brace                               space-before-blocks
   42:8    error  Expected indentation of 8 characters                             indent
   42:26   error  Trailing spaces not allowed                                      no-trailing-spaces
   43:16   error  Missing parentheses around multilines JSX                        react/wrap-multilines
   43:80   error  "optionSelectedStyle" used outside of binding context            block-scoped-var
   44:33   error  "optionIconSelectedStyle" used outside of binding context        block-scoped-var
   47:33   error  "selectedPinkStyle" used outside of binding context              block-scoped-var
   48:46   error  Trailing spaces not allowed                                      no-trailing-spaces
   49:6    error  Expected indentation of 6 characters                             indent
   51:6    error  Expected indentation of 6 characters                             indent
   51:8    error  All "var" declarations must be at the top of the function scope  vars-on-top
   51:8    error  Unexpected var, use let or const instead                         no-var
   51:29   error  Trailing spaces not allowed                                      no-trailing-spaces
   52:12   error  Missing parentheses around multilines JSX                        react/wrap-multilines
   52:75   error  "optionStyle" used outside of binding context                    block-scoped-var
   52:75   error  optionStyle was used before it was defined                       no-use-before-define
   52:101  error  Missing function expression name                                 func-names
   52:111  error  Missing space before opening brace                               space-before-blocks
   52:134  error  Missing semicolon                                                semi
   55:6    error  Expected indentation of 6 characters                             indent
   55:8    error  Keyword "if" must be followed by whitespace                      space-after-keywords
   55:27   error  Expected '===' and instead saw '=='                              eqeqeq
   55:41   error  Missing space before opening brace                               space-before-blocks
   56:8    error  Expected indentation of 8 characters                             indent
   57:16   error  Missing parentheses around multilines JSX                        react/wrap-multilines
   57:80   error  "optionSelectedStyle" used outside of binding context            block-scoped-var
   58:33   error  "optionIconSelectedStyle" used outside of binding context        block-scoped-var
   61:33   error  "selectedPinkStyle" used outside of binding context              block-scoped-var
   62:58   error  Trailing spaces not allowed                                      no-trailing-spaces
   63:6    error  Expected indentation of 6 characters                             indent
   65:6    error  Expected indentation of 6 characters                             indent
   65:8    error  All "var" declarations must be at the top of the function scope  vars-on-top
   65:8    error  Unexpected var, use let or const instead                         no-var
   65:26   error  Trailing spaces not allowed                                      no-trailing-spaces
   66:12   error  Missing parentheses around multilines JSX                        react/wrap-multilines
   66:72   error  "optionStyle" used outside of binding context                    block-scoped-var
   66:72   error  optionStyle was used before it was defined                       no-use-before-define
   66:98   error  Missing function expression name                                 func-names
   66:108  error  Missing space before opening brace                               space-before-blocks
   66:128  error  Missing semicolon                                                semi
   69:6    error  Expected indentation of 6 characters                             indent
   69:8    error  Keyword "if" must be followed by whitespace                      space-after-keywords
   69:27   error  Expected '===' and instead saw '=='                              eqeqeq
   69:38   error  Missing space before opening brace                               space-before-blocks
   70:8    error  Expected indentation of 8 characters                             indent
   70:26   error  Trailing spaces not allowed                                      no-trailing-spaces
   71:16   error  Missing parentheses around multilines JSX                        react/wrap-multilines
   71:80   error  "optionSelectedStyle" used outside of binding context            block-scoped-var
   72:33   error  "optionIconSelectedStyle" used outside of binding context        block-scoped-var
   75:33   error  "selectedPinkStyle" used outside of binding context              block-scoped-var
   77:6    error  Expected indentation of 6 characters                             indent
   79:6    error  Expected indentation of 6 characters                             indent
   79:8    error  All "var" declarations must be at the top of the function scope  vars-on-top
   79:8    error  Unexpected var, use let or const instead                         no-var
   79:28   error  Trailing spaces not allowed                                      no-trailing-spaces
   80:12   error  Missing parentheses around multilines JSX                        react/wrap-multilines
   80:74   error  optionStyle was used before it was defined                       no-use-before-define
   80:74   error  "optionStyle" used outside of binding context                    block-scoped-var
   80:100  error  Missing function expression name                                 func-names
   80:110  error  Missing space before opening brace                               space-before-blocks
   80:132  error  Missing semicolon                                                semi
   83:6    error  Expected indentation of 6 characters                             indent
   83:8    error  Keyword "if" must be followed by whitespace                      space-after-keywords
   83:27   error  Expected '===' and instead saw '=='                              eqeqeq
   83:40   error  Missing space before opening brace                               space-before-blocks
   84:8    error  Expected indentation of 8 characters                             indent
   84:28   error  Trailing spaces not allowed                                      no-trailing-spaces
   85:16   error  Missing parentheses around multilines JSX                        react/wrap-multilines
   85:80   error  "optionSelectedStyle" used outside of binding context            block-scoped-var
   86:33   error  "optionIconSelectedStyle" used outside of binding context        block-scoped-var
   89:33   error  "selectedPinkStyle" used outside of binding context              block-scoped-var
   91:6    error  Expected indentation of 6 characters                             indent
   93:6    error  Expected indentation of 6 characters                             indent
   93:8    error  All "var" declarations must be at the top of the function scope  vars-on-top
   93:8    error  Unexpected var, use let or const instead                         no-var
   94:12   error  Missing parentheses around multilines JSX                        react/wrap-multilines
   94:72   error  optionStyle was used before it was defined                       no-use-before-define
   94:72   error  "optionStyle" used outside of binding context                    block-scoped-var
   94:98   error  Missing function expression name                                 func-names
   94:108  error  Missing space before opening brace                               space-before-blocks
   94:128  error  Missing semicolon                                                semi
   96:29   error  Missing semicolon                                                semi
   97:6    error  Expected indentation of 6 characters                             indent
   97:8    error  Keyword "if" must be followed by whitespace                      space-after-keywords
   97:27   error  Expected '===' and instead saw '=='                              eqeqeq
   97:38   error  Missing space before opening brace                               space-before-blocks
   98:8    error  Expected indentation of 8 characters                             indent
   98:26   error  Trailing spaces not allowed                                      no-trailing-spaces
   99:16   error  Missing parentheses around multilines JSX                        react/wrap-multilines
   99:80   error  "optionSelectedStyle" used outside of binding context            block-scoped-var
  100:33   error  "optionIconSelectedStyle" used outside of binding context        block-scoped-var
  103:33   error  "selectedPinkStyle" used outside of binding context              block-scoped-var
  105:6    error  Expected indentation of 6 characters                             indent
  107:6    error  Expected indentation of 6 characters                             indent
  108:36   error  modeStyle was used before it was defined                         no-use-before-define
  108:36   error  "modeStyle" used outside of binding context                      block-scoped-var
  120:0    error  Unexpected var, use let or const instead                         no-var
  131:1    error  Missing semicolon                                                semi
  133:0    error  Unexpected var, use let or const instead                         no-var
  144:1    error  Missing semicolon                                                semi
  146:0    error  Unexpected var, use let or const instead                         no-var
  149:1    error  Missing semicolon                                                semi
  151:0    error  Unexpected var, use let or const instead                         no-var
  152:12   error  Missing space before value for key "display"                     key-spacing
  153:13   error  Missing space before value for key "position"                    key-spacing
  154:10   error  Missing space before value for key "width"                       key-spacing
  159:0    error  Unexpected var, use let or const instead                         no-var
  159:4    error  optionArrowDownSmall is defined but never used                   no-unused-vars
  160:42   error  Infix operators must be spaced                                   space-infix-ops
  161:1    error  Missing semicolon                                                semi
  163:0    error  Unexpected var, use let or const instead                         no-var
  165:1    error  Missing semicolon                                                semi
以下是我的Web包配置,用于该文件不产生错误的项目:

"babel": "^5.6.14",
"babel-core": "^5.6.15",
"babel-eslint": "^3.1.18",
"babel-jest": "^5.0.1",
"babel-loader": "^5.3.1",
"babel-plugin-object-assign": "^1.1.0",
"bundle-loader": "^0.5.4",
"babel-plugin-flow-comments": "^1.0.9",
“严格使用”;
var webpack=require('webpack');
module.exports={
devtool:'sourcemap',
条目:'./app/index.js',
输出:{
文件名:“bundle.js”,
},
模块:{
装载机:[
{
测试:/\.js$/,,
装载机:[
“巴贝尔”
]
},
{test:/\.jsx$/,加载程序:['babel']},
{ 
测试:/\.减去$/,,
加载器:“样式加载器!css加载器!更少加载器”
},
{ 
测试:/\.css$/,,
加载器:“样式加载器!css加载器”
},
{ 
测试:/\(png | jpg | gif | otf | eot | svg | ttf | woff)$/,
加载器:“url加载器?限制=8192”

}//在第二个配置中,您正在运行eslint的的内联base64 URL

preLoaders: [{
  test: /\.js$|\.jsx$/,
  exclude: /node_modules/,
  loaders: ["eslint"]
}],
EsLint将检查代码中的常见问题,并强制执行所选的样式格式。这就是为什么会出现所有这些错误

请在此处阅读有关绒线的更多信息:


如果使用此配置将代码导入到现有项目中,为什么不修复“挑剔”问题?原始开发人员可能希望在整个代码库中使用一致的样式。

在第二个配置中,您正在运行eslint

preLoaders: [{
  test: /\.js$|\.jsx$/,
  exclude: /node_modules/,
  loaders: ["eslint"]
}],
EsLint将检查代码中的常见问题,并强制执行所选的样式格式。这就是为什么会出现所有这些错误

请在此处阅读有关绒线的更多信息:


如果使用此配置将代码导入到现有项目中,为什么不修复“挑剔”问题?原始开发人员可能希望在整个代码库中使用一致的样式。

在第二个配置中,您正在运行eslint

preLoaders: [{
  test: /\.js$|\.jsx$/,
  exclude: /node_modules/,
  loaders: ["eslint"]
}],
EsLint将检查代码中的常见问题,并强制执行所选的样式格式。这就是为什么会出现所有这些错误

请在此处阅读有关绒线的更多信息:


如果使用此配置将代码导入到现有项目中,为什么不修复“挑剔”问题?原始开发人员可能希望在整个代码库中使用一致的样式。

在第二个配置中,您正在运行eslint

preLoaders: [{
  test: /\.js$|\.jsx$/,
  exclude: /node_modules/,
  loaders: ["eslint"]
}],
EsLint将检查代码中的常见问题,并强制执行所选的样式格式。这就是为什么会出现所有这些错误

请在此处阅读有关绒线的更多信息:

如果要将代码导入到具有此配置的现有项目中,为什么不修复“挑剔”问题?原始开发人员可能希望在整个代码库中使用一致的样式