admin管理员组文章数量:1426058
Im trying to resolve the issue I encounter when Im trying to update jest in my package.json
jest 26.6.3 → 27.0.1
Im receiving error
TypeError: require(...).createTransformer is not a function
at Object.<anonymous> (/local/repo/elukchm/monorepo/packages/edf/jestPreprocess.js:34:40)
at Module._pile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
The code mentioned in files:
jestPreprocess.js
const babelOptions = {
...
};
module.exports = require("babel-jest").createTransformer(babelOptions);
Inside "babel-jest"
const createTransformer = userOptions => {
var _inputOptions$plugins, _inputOptions$presets;
const inputOptions =
userOptions !== null && userOptions !== void 0 ? userOptions : {};
const options = {
...
};
Could you please take a look and tell what should I change? Thank you in advance.
Im trying to resolve the issue I encounter when Im trying to update jest in my package.json
jest 26.6.3 → 27.0.1
Im receiving error
TypeError: require(...).createTransformer is not a function
at Object.<anonymous> (/local/repo/elukchm/monorepo/packages/edf/jestPreprocess.js:34:40)
at Module._pile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
The code mentioned in files:
jestPreprocess.js
const babelOptions = {
...
};
module.exports = require("babel-jest").createTransformer(babelOptions);
Inside "babel-jest"
const createTransformer = userOptions => {
var _inputOptions$plugins, _inputOptions$presets;
const inputOptions =
userOptions !== null && userOptions !== void 0 ? userOptions : {};
const options = {
...
};
Could you please take a look and tell what should I change? Thank you in advance.
Share Improve this question edited May 27, 2021 at 12:20 Elcardia asked May 27, 2021 at 12:11 ElcardiaElcardia 1651 silver badge11 bronze badges 01 Answer
Reset to default 8babel-jest@27
switched to ESM, so require
is now getting the whole exported scope rather than just the default. Super simple to fix:
module.exports = require("babel-jest").createTransformer(babelOptions);
-->
module.exports = require("babel-jest").default.createTransformer(babelOptions);
本文标签: javascriptNodejs TypeError require()() is not a funcStack Overflow
版权声明:本文标题:javascript - Nodejs: TypeError: require().() is not a func - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745404449a2657187.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论