提问者:小点点

模块生成失败:ReferenceError:[BABEL]未知选项:/users/will/.Babelrc.presets


所以我对此完全感到困惑。我的团队运行在同一个分支上,同一个代码提交上。我是唯一有这个问题的人。下面是完整的堆栈跟踪:

Module build failed: ReferenceError: [BABEL] /Users/Will/Brandzooka/visibl-front_end/node_modules/eslint-loader/index.js!/Users/Will/Brandzooka/visibl-front_end/app/index.jsx: Unknown option: /Users/Will/.babelrc.presets
    at Logger.error (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/file/logger.js:58:11)
    at OptionManager.mergeOptions (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/file/options/option-manager.js:126:29)
    at OptionManager.addConfig (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/file/options/option-manager.js:107:10)
    at OptionManager.findConfigs (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/file/options/option-manager.js:168:35)
    at OptionManager.init (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229:12)
    at File.initOptions (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/file/index.js:147:75)
    at new File (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/file/index.js:137:22)
    at Pipeline.transform (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/pipeline.js:164:16)
    at transpile (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-loader/index.js:12:22)
    at Object.module.exports (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-loader/index.js:69:12)

我遇到了多个答案,都与巴别塔6的用法有关,但目前对我并不适用。

我试过:

  • 卸载和重新安装节点和npm版本(通过nvm)
  • 删除所有节点模块,然后重新安装
  • NPM缓存清除
  • 取消回购和重新克隆
  • 为了更好地衡量,请重新启动我的计算机

Im running node V0.12.9和npm V2.14.9

这是我的package.json

{
  "version": "0.0.0",
  "main": "app/index.js",
  "private": true,
  "scripts": {
    "build": "CONFIG_ENV=dev Q_DEBUG=1 time ./node_modules/.bin/webpack --config conf/webpack.production.js",
    "build:prod": "CONFIG_ENV=production time ./node_modules/.bin/webpack --config conf/webpack.production.js",
    "build:stage": "CONFIG_ENV=stage time ./node_modules/.bin/webpack --config conf/webpack.production.js",
    "deploy:codeship-getvisibl": "time firebase deploy --token $FIREBASETOKEN",
    "deploy:codeship-stage": "time firebase deploy --token $FIREBASETOKEN --project firebase-visibl-stage",
    "deploy:stage": "firebase use firebase-visibl-stage && firebase deploy",
    "lint": "PATH=$PATH:/usr/local/bin time ./node_modules/eslint/bin/eslint.js --cache --format 'node_modules/eslint-friendly-formatter' --ext .js --ext .jsx --config .eslintrc app/",
    "migrate": "babel-node --stage 1 migrate.js",
    "start": "CONFIG_ENV=dev Q_DEBUG=1 ./node_modules/.bin/webpack-dev-server --config conf/webpack.config.js --hot --progress --inline --content-base ./build",
    "start:prod": "CONFIG_ENV=production Q_DEBUG=1 ./node_modules/.bin/webpack-dev-server --config conf/webpack.config.js --hot --progress --inline --content-base ./build",
    "debug": "CONFIG_ENV=dev Q_DEBUG=1 time ./node_modules/.bin/mocha debug --full-trace --colors --recursive  app/mochaNodeSetup.js app",
    "test": "CONFIG_ENV=dev Q_DEBUG=1 time ./node_modules/.bin/mocha --full-trace --colors --bail --recursive  app/mochaNodeSetup.js app"
  },
  "dependencies": {
    "@brandzooka/client": "*",
    "@brandzooka/models": "*",
    "autoprefixer-loader": "2.0.0",
    "aws-sdk": "^2.3.7",
    "babel-core": "5.8.38",
    "babel-loader": "5.3.2",
    "baconjs": "0.7.66",
    "bluebird": "2.10.1",
    "bootstrap-sass": "3.3.5",
    "bootstrap-slider": "4.10.0",
    "chai": "3.0.0",
    "chai-immutable": "1.0.2",
    "classnames": "2.1.2",
    "clear-require": "^1.0.1",
    "cls-bluebird": "^1.0.1",
    "css-loader": "0.15.1",
    "dom-scroll-into-view": "1.2.0",
    "eslint": "1.4.3",
    "eslint-friendly-formatter": "1.0.8",
    "eslint-loader": "^1.0.0",
    "eslint-plugin-mocha": "0.4.0",
    "eslint-plugin-react": "3.4.1",
    "exports-loader": "0.6.2",
    "file-loader": "0.8.4",
    "immutable": "3.7.4",
    "immutable-form-validation": "1.0.4",
    "imports-loader": "0.6.4",
    "jquery": "2.1.4",
    "jsdom": "2.0.0",
    "json-loader": "0.5.2",
    "lodash": "3.10.1",
    "mocha": "2.2.5",
    "moment": "2.10.3",
    "node-libs-browser": "0.5.2",
    "node-sass": "3.2.0",
    "nomnom": "^1.8.1",
    "null-loader": "0.1.1",
    "phantomjs": "1.9.18",
    "precommit-hook": "2.0.1",
    "q": "1.4.1",
    "query-string": "3.0.3",
    "rc-form-validation": "2.4.12",
    "react": "^0.14.0",
    "react-addons-pure-render-mixin": "0.14.0",
    "react-addons-test-utils": "0.14.0",
    "react-bootstrap": "0.29.5",
    "react-bootstrap-daterangepicker": "0.2.5",
    "react-dom": "0.14.0",
    "react-dropzone": "1.2.2",
    "react-hot-loader": "1.2.7",
    "react-moment-proptypes": "0.0.5",
    "react-router": "0.13.5",
    "react-slick": "0.12.2",
    "readline2": "^1.0.1",
    "reflux": "0.4.1",
    "reflux-core": "0.3.0",
    "reflux-promise": "1.0.4",
    "sass-loader": "1.0.2",
    "sha.js": "2.4.5",
    "sinon": "1.15.4",
    "sinon-chai": "2.8.0",
    "sinon-react": "0.2.1",
    "style-loader": "0.12.3",
    "superagent": "1.2.0",
    "superagent-promise": "1.0.0",
    "url": "0.10.3",
    "url-loader": "0.5.6",
    "uuid": "2.0.2",
    "valid-url": "1.0.9",
    "whatwg-fetch": "0.9.0"
  },
  "devDependencies": {
    "babel": "5.8.38",
    "babel-eslint": "^6.0.0-beta.6",
    "chai-spies": "^0.7.1",
    "clean-webpack-plugin": "0.1.3",
    "estraverse": "^4.2.0",
    "extract-text-webpack-plugin": "0.8.2",
    "firebase-token-generator": "^2.0.0",
    "html-webpack-plugin": "1.5.2",
    "pg": "^4.4.2",
    "pg-parse-float": "0.0.1",
    "webpack": "*",
    "webpack-dev-server": "*"
  }
}

有什么好点子吗?三个小时后,我甚至不能得到错误信息更改。


共1个答案

匿名用户

配置路径/users/will/.babelrc.presets意味着您在/users/will/中有一个.babelrc文件,并且它有一个“presets”键,因为它似乎是Babel 6的配置文件。

想必您在/users/will/brandzooka/visibl-front_end/.babelrc上有一个.babelrc来配置您的Babel5安装,但是除非您告诉它,否则Babel5不会停止向上遍历查找其他配置(Babel6停止在第一个配置),所以它还会进一步查找您主目录中的Babel6配置并出错。

这给您留下了几个选择:

  • 删除/users/will/.babelrc,因为Babel配置文件应位于它们所应用的项目中,而不是位于您的家中。
  • 如果不允许,请打开(也可以创建)/users/will/brandzooka/visibl-front_end/.babelrc并确保它具有键“breakconfig”:true以告知Babel 5停止在父目录中查找其他配置文件。