question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: require.resolve is not a function

See original GitHub issue

I 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

  1. socket.io was used instead of socket.io-client; or
  2. 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:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jaredallardcommented, Feb 8, 2017

@Thor19 so you can use global.require in place of require(), 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 in node_modules (so that must be shipped as well).

0reactions
amilajackcommented, May 31, 2017

Should this be closed?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found