模块构建失败:ReferenceError:[BABEL]未知选项:/Users/Will/.babelrc.presets

时间:2016-07-25 23:17:22

标签: node.js npm babeljs

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

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)

我发现了多个与Babel 6用法相关的答案,这些答案目前不适用于我。

我试过了:

  • 卸载并重新安装node和npm版本(通过nvm)
  • 吹走所有节点模块,然后重新安装
  • npm cache clean
  • 吹走回购,并重新克隆
  • 为了更好的衡量,重新启动我的机器

我正在运行节点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": "*"
  }
}

那里有什么好主意吗? 3个小时后,我甚至无法收到错误消息。

1 个答案:

答案 0 :(得分:4)

配置路径/Users/Will/.babelrc.presets表示您在.babelrc中有一个/Users/Will/文件,并且它有一个"presets"密钥,因为它似乎是Babel 6的配置文件。

大概你在.babelrc /Users/Will/Brandzooka/visibl-front_end/.babelrc配置你的Babel 5安装,但是Babel 5并没有停止向上寻找其他配置,除非你告诉它(Babel 6停在第一个配置),所以它也会在主目录中的Babel 6配置上看起来更远并且出错。

这为您提供了一些选择:

  • 删除/Users/Will/.babelrc,因为Babel配置文件应该存在于他们申请的项目中,而不是在您的家中。
  • 如果这是禁止,打开(并且可能创建)/Users/Will/Brandzooka/visibl-front_end/.babelrc并确保它具有密钥"breakConfig": true以告知Babel 5停止在父目录中查找其他配置文件。< / LI>