在我的package.json
中,我具有以下依赖性:
"mocha": "^5.2.x",
"babel-core": "^6.26.3",
"babel-loader": "^6.4.1",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-1": "^6.24.1"
当我尝试使用./node_modules/mocha/bin/mocha --require babel-polyfill --require babel-register --recursive ./tests/**
运行测试时,出现以下错误:
/Volumes/SourceRepos/central-ui/node_modules-Darwin/babel-core/lib/transformation/file/options/option-manager.js:328
throw e;
^
Error: Options {"loose":true} passed to /Volumes/SourceRepos/central-ui/node_modules-Darwin/babel-preset-env/lib/index.js which does not accept options. (While processing preset: "/Volumes/SourceRepos/central-ui/node_modules-Darwin/babel-preset-env/lib/index.js") (While processing preset: "/Volumes/SourceRepos/central-ui/node_modules-Darwin/babel-preset-env/lib/index.js") (While processing preset: "/Volumes/SourceRepos/central-ui/node_modules-Darwin/babel-preset-react/lib/index.js")
at /Volumes/SourceRepos/central-ui/node_modules-Darwin/babel-core/lib/transformation/file/options/option-manager.js:314:17
at Array.map (<anonymous>)
at OptionManager.resolvePresets (/Volumes/SourceRepos/central-ui/node_modules-Darwin/babel-core/lib/transformation/file/options/option-manager.js:275:20)
at OptionManager.mergePresets (/Volumes/SourceRepos/central-ui/node_modules-Darwin/babel-core/lib/transformation/file/options/option-manager.js:264:10)
at OptionManager.mergeOptions (/Volumes/SourceRepos/central-ui/node_modules-Darwin/babel-core/lib/transformation/file/options/option-manager.js:249:14)
at OptionManager.init (/Volumes/SourceRepos/central-ui/node_modules-Darwin/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at compile (/Volumes/SourceRepos/central-ui/node_modules-Darwin/babel-register/lib/node.js:103:45)
at loader (/Volumes/SourceRepos/central-ui/node_modules-Darwin/babel-register/lib/node.js:144:14)
at Object.require.extensions.(anonymous function) [as .js] (/Volumes/SourceRepos/central-ui/node_modules-Darwin/babel-register/lib/node.js:154:7)
...
我最近从^3.2.x
版本更新了Mocha。使用Mocha 3.2,使用同一命令运行的测试没有问题。我使用的是node.js 8.x LTS(在撰写本文时为8.13)
任何想法如何解决此问题?谢谢。