我正在使用npm,coffee script和jest建立一个构建,但是我看到了神秘的错误-显然是来自babel配置。
npm运行测试
...
插件/预设文件不允许导出对象,只能导出功能。在/Users/tonyofthewoods/worktuna/temptest/node_modules/babel-preset-jest/index.js
at createDescriptor (node_modules/@babel/core/lib/config/config-descriptors.js:178:11)
...
完整项目位于this github repo.
package.json
{
"name": "temp_test",
"version": "0.0.1",
"private": true,
"main": "index.js",
"scripts": {
"build": "rollup -c",
"test": "jest src"
},
"keywords": [
"app"
],
"author": "The Author",
"license": "UNLICENSED",
"bugs": {
"url": "https://example.com/temptest/isssues"
},
"homepage": "https://example.com/temptest#readme",
"babel": {
"presets": [
"@babel/env"
]
},
"jest": {
"preset": "jest-preset-coffeescript",
"testRegex": ".*\\.test\\.(coffee|litcoffee|coffee.md)$"
},
"dependencies": {
"lodash": "^4.17.11"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.3",
"@babel/polyfill": "^7.2.5",
"@babel/preset-env": "^7.3.1",
"@babel/register": "^7.0.0",
"copyfiles": "^2.1.0",
"eslint": "^5.16.0",
"eslint-plugin-coffeescript": "^1.0.0",
"jest": "^21.1.0",
"jest-preset-coffeescript": "^1.0.0",
"rimraf": "^2.6.3",
"rollup": "^1.9.0",
"rollup-plugin-coffee-script": "^2.0.0",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-node-resolve": "^4.2.1"
}
}
我读过线程,在打字稿中会发生类似的问题并做出反应-在这种情况下,答案是确保所有babel组件都来自babel 7的@babel命名空间。
但是package-lock.json中的babel-preset-jest是“ ^ 21.2.0”,我相信这是最新的和最大的。