create-react-app执行npm test报错
报错信息如下
FAIL src/App.test.js
● Test suite failed to run
ReferenceError: [BABEL] C:\Users\htbst\Desktop\woyin-h5\src\App.test.js: Unknown option: base.configFile. Check out http://babeljs.io/docs/usage/options/ for more information about options.
A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:
Invalid:
`{ presets: [{option: value}] }`
Valid:
`{ presets: [['presetName', {option: value}]] }`
For more detailed information on preset configuration, please see https://babeljs.io/docs/en/plugins#pluginpresets-options.
at Logger.error (node_modules/_babel-core@6.26.3@babel-core/lib/transformation/file/logger.js:41:11)
at OptionManager.mergeOptions (node_modules/_babel-core@6.26.3@babel-core/lib/transformation/file/options/option-manager.js:226:20)
at OptionManager.init (node_modules/_babel-core@6.26.3@babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (node_modules/_babel-core@6.26.3@babel-core/lib/transformation/file/index.js:212:65)
at new File (node_modules/_babel-core@6.26.3@babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (node_modules/_babel-core@6.26.3@babel-core/lib/transformation/pipeline.js:46:16)
package.json
{
"name": "react_demo",
"version": "0.1.0",
"private": true,
"homepage": "/",
"dependencies": {
"@babel/polyfill": "^7.4.3",
"amfe-flexible": "^2.2.1",
"axios": "^0.18.0",
"classnames": "^2.2.6",
"dayjs": "^1.8.12",
"jwt-decode": "^2.2.0",
"md5": "^2.2.1",
"moment": "^2.24.0",
"qs": "^6.7.0",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-helmet": "^5.2.0",
"react-loadable": "^5.5.0",
"react-motion": "^0.5.2",
"react-redux": "^6.0.0",
"react-refetch": "^2.0.3",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.1",
"react-transition-group": "^2.5.2",
"recompose": "^0.30.0",
"redux": "^4.0.1",
"redux-form-utils": "^1.1.2",
"redux-thunk": "^2.3.0",
"styled-components": "^4.1.3",
"uuid": "^3.3.2",
"vconsole": "^3.3.0",
"weui": "^1.1.3",
"weui.js": "^1.1.4"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"babel-core": "^6.26.3",
"http-proxy-middleware": "^0.19.1",
"mockjs": "^1.0.1-beta3",
"pretender": "^2.1.1",
"react-app-rewired": "^2.1.1",
"webpack-bundle-analyzer": "^3.3.2"
}
}
config-overrides.js
const path = require('path')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
function resolve (dir) {
return path.join(__dirname, dir)
}
module.exports = function override(config, env) {
config.resolve.alias['@'] = resolve('src')
if(env === 'production') {
config.externals = {
'react': 'React',
'react-dom': 'ReactDOM'
}
// config.plugins.push(new BundleAnalyzerPlugin())
}
// do stuff with the webpack config...
return config
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 https://github.com/facebook/c...
应该是 babel-core 的版本问题,使用 "babel-core": "7.0.0-bridge.0" 代替 "babel-core": "^6.26.3" 应该可以解决。
script脚本命令除了start可以直接npm start , 其他的都是npm run * 这样的命令,比如 npm run test