我在运行JEST时遇到了通天塔问题。这是我的.babelrc:
{
"presets": [
"es2015", "react"
],
"plugins": [
["babel-plugin-root-import", {
"rootPathSuffix": "src"
}],
"transform-object-rest-spread",
"transform-class-properties",
"syntax-dynamic-import"
]
}
然后,当我运行yarn test
时,出现此错误:
Plugin/Preset files are not allowed to export objects, only functions. In /Users/blah/blah
node_modules/babel-preset-es2015/lib/index.js
我对Package.json的开发依赖项是
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.2",
"babel-jest": "^24.8.0",
"babel-loader": "^7.1.4",
"babel-plugin-lodash": "^3.3.2",
"babel-plugin-root-import": "^5.1.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^0.28.10",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.13.1",
"eslint": "^4.18.2",
"eslint-config-airbnb": "^16.1.0",
"eslint-loader": "^2.0.0",
"eslint-plugin-import": "^2.9.0",
"extract-text-webpack-plugin": "^4.0.0-alpha.0",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.0.6",
"jest-cli": "^24.8.0",
"node-sass": "^4.7.2",
"postcss-loader": "^2.1.1",
"rimraf": "^2.6.2",
"sass-loader": "^6.0.7",
"style-loader": "^0.20.3",
"webpack": "^4.29.3",
"webpack-cli": "^3.2.3",
"webpack-dev-server": "^3.1.14"
}
我尝试将babel-preset-es2015更改为babel-preset-env,但是存在相同的问题。