TypeError: require.resolve is not a function
See original GitHub issueI used nexe to wrap my node.js application with the following config in package.json:
"nexe": {
"input": "/usr/local/bin/nexe",
"output": "myApp.nexe^$",
"temp": "temp",
"runtime": {
"framework": "node",
"version": "5.5.0",
"ignoreFlags": false
}
The executable was generated but when I run it, it reported the following error:
$ ./myApp.nexe
nexe.js:25933
var processPath = require.resolve('process/browser.js');
^
TypeError: require.resolve is not a function
at Object.__dirname.150.combine-source-map (nexe.js:25933:27)
at s (nexe.js:1:316)
at nexe.js:1:367
at Object.<anonymous> (nexe.js:11548:21)
at Object.__dirname.34../lib/builtins.js (nexe.js:12350:4)
at s (nexe.js:1:316)
at nexe.js:1:367
at Object.__dirname.2../log (nexe.js:140:21)
at s (nexe.js:1:316)
at nexe.js:1:367
Google search suggested this error might be due to
- socket.io was used instead of socket.io-client; or
- the used browserify doesn’t support “require.resolve” while “require” should be used
My app doesn’t use socket.io. And almost all of the libraries my app depends on use the same version of browserify as nexe uses (^13.0.0), except the bluebird library which uses ^8.1.1. I am not sure if that is related. My app doesn’t have any code using “require.resolve(‘process/browser.js’)”. It seems the error happens in the code generated by nexe. So hope I can get some help here.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:7 (3 by maintainers)
Top Results From Across the Web
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 >TypeError: require.resolve is not a function - Bountysource
I used nexe to wrap my node.js application with the following config in package.json: "nexe": { "input": "/usr/local/bin/nexe", ...
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 Free
Top 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

@Thor19 so you can use
global.requirein place ofrequire(), but this make it use the native node.js version of require. This means that it won’t use the bundled version, and will instead use the one innode_modules(so that must be shipped as well).Should this be closed?