React 0.14错误:模块构建失败:ReferenceError:[BABEL] ... / node_modules / eslint-loader / index.js!/.../ main.jsx:未知选项:base.stage

时间:2015-11-10 13:05:12

标签: reactjs eslint

这是我的package.json:

  "scripts": {
    "test": "echo \"Error: no test specified\n\" && exit 1",
    "lint": "npm run lint-js && npm run lint-css",
    "lint-js": "echo \"\\033[33mLinting JS\\033[0m\n\" && eslint . --ext .js --ext .jsx",
    "lint-css": "echo \"\\033[33mLinting CSS\\033[0m\n\" && csslint app/style --quiet",
    "start": "echo \"\\033[33mStarting dev server at localhost:8080\\033[0m\n\" && TARGET=dev webpack-dev-server --devtool eval-source --progress --colors --hot --inline --history-api-fallback",
    "compile": "echo \"\\033[33mBuilding for production\\033[0m\n\" && TARGET=build webpack -p",
    "build": "npm run lint-js && npm run lint-css && npm run compile"
  },
  "private": true,
  "dependencies": {
    "alt": "^0.17.8",
    "babel-core": "^6.1.2",
    "babel-loader": "^6.1.0",
    "babelify": "^7.2.0",
    "css-loader": "^0.22.0",
    "csslint": "^0.10.0",
    "csslint-loader": "^0.2.1",
    "eslint": "^1.9.0",
    "eslint-plugin-react": "^3.8.0",
    "file-loader": "^0.8.4",
    "flowcheck": "^0.2.7",
    "flowcheck-loader": "^1.0.0",
    "gsap": "^1.18.0",
    "html-webpack-plugin": "^1.6.2",
    "jquery-browserify": "^1.8.1",
    "node-libs-browser": "^0.5.3",
    "radium": "^0.14.3",
    "react": "^0.14.2",
    "react-bootstrap": "^0.27.3",
    "react-bootstrap-modal": "^2.0.0",
    "react-dom": "^0.14.2",
    "react-hot-loader": "^1.3.0",
    "react-odometer": "0.0.1",
    "react-slick": "^0.9.1",
    "react-swf": "^0.13.0",
    "style-loader": "^0.13.0",
    "superagent": "^1.4.0",
    "url-loader": "^0.5.6",
    "video.js": "^5.0.2",
    "webpack": "^1.12.3",
    "webpack-dev-server": "^1.12.1",
    "webpack-merge": "^0.2.0"
  }
}

这是完整的错误消息,我读到这个错误可以使用babelify解决,所以我添加了它,虽然我不需要它。

./app /

中的错误
main.jsx
Module build failed: ReferenceError: [BABEL] /Dev/Fanatico/node_modules/eslint-loader/index.js!/Dev/Fanatico/app/main.jsx: Unknown option: base.stage
    at Logger.error (/Dev/Fanatico/node_modules/babel-core/lib/transformation/file/logger.js:43:11)
    at OptionManager.mergeOptions (/Dev/Fanatico/node_modules/babel-core/lib/transformation/file/options/option-manager.js:245:18)
    at OptionManager.init (/Dev/Fanatico/node_modules/babel-core/lib/transformation/file/options/option-manager.js:396:10)
    at File.initOptions (/Dev/Fanatico/node_modules/babel-core/lib/transformation/file/index.js:191:75)
    at new File (/Dev/Fanatico/node_modules/babel-core/lib/transformation/file/index.js:122:22)
    at Pipeline.transform (/Dev/Fanatico/node_modules/babel-core/lib/transformation/pipeline.js:42:16)
    at transpile (/Dev/Fanatico/node_modules/babel-loader/index.js:14:22)
    at Object.module.exports (/Dev/Fanatico/node_modules/babel-loader/index.js:83:14)
 @ multi main

当我想升级到React 0.14并最终逐个安装所有软件包时,这一切都开始了。

2 个答案:

答案 0 :(得分:23)

您需要安装:

  • 巴别核
  • 巴别装载机
  • 巴别预置-ES2015
  • 巴别预置反应的
  • 巴别预置级-0

package.json 中的依赖项将是:

{
  "name": "react-transform-example",
  "devDependencies": {
    "babel-core": "^6.0.20",
    "babel-loader": "^6.0.1",
    "babel-preset-es2015": "^6.0.15",
    "babel-preset-react": "^6.0.15",
    "babel-preset-stage-0": "^6.0.15",
    "express": "^4.13.3",
    "webpack": "^1.9.6"
  },
  "dependencies": {
    "react": "^0.14.0",
    "react-dom": "^0.14.0"    
  }
}

您的 .babelrc 文件

{
  "presets": ["es2015", "stage-0", "react"]
}

setting-up-babel-6

的更多信息

答案 1 :(得分:10)

你正在使用没有舞台选项的babel 6,而是你必须使用预设,例如:

http://babeljs.io/docs/plugins/#presets

http://babeljs.io/docs/plugins/preset-stage-0/

  

安装

     

$ npm install babel-preset-stage-0

     

用法

     

将以下行添加到.babelrc文件中:

     

{"presets": ["stage-0"] }

请注意,您还需要es2015react预设。另请注意,至少有一些热重装插件尚未兼容。