TypeError: __require.resolve is not a function
See original GitHub issueHello! I have an issue with the tsup
, I have a TypeScript project with require.resolve
function, with pure tsc
it works, but when I try to build with tsup-node
I get this error:
TypeError: __require.resolve is not a function
I made a reproduction repo for this issue: https://github.com/mvrlin/tsup-require-resolve
I came across this “solution”:
// Before
var __require = (x) => {
if (typeof require !== "undefined")
return require(x);
throw new Error('Dynamic require of "' + x + '" is not supported');
};
// After
var __require = (x) => {
throw new Error('Dynamic require of "' + x + '" is not supported');
}
if (typeof require !== "undefined") {
__require = require
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top Results From Across the Web
TypeError: require.resolve is not a function · Issue #213 - GitHub
A workaround for this is to use node's require via global.require . It looks like a module you're using is using it, this...
Read more >node.js - require.resolve() works. Why doesn't module.parent ...
TypeError : module.parent.require.resolve is not a function. Oddly though, console.log module.parent.require.toString() returns .
Read more >TypeError: require(...) is not a function in Node.js | bobbyhadz
To solve the "TypeError: require(...) is not a function", make sure to place a semicolon between your require call and an immediately invoked...
Read more >Node.js v19.3.0 Documentation
If the function does not return a promise, assert.rejects() will return a rejected Promise with an ERR_INVALID_RETURN_VALUE error. In both cases the error ......
Read more >How to solve the "is not a function" error in JavaScript
js we use require() to load external modules and files. This can cause, in some cases, an error like this: TypeError: require(...) is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Since esbuild 0.12.26, this issue should be solved automatically by updating dependencies. (
npm update
) @mvrlin Can you confirm that?@screetBloom Yes that should work, but it will lose code splitting.