Skip to content

Conversation

@PenguinDevs
Copy link

See #168.

@CLAassistant
Copy link

CLAassistant commented Jan 10, 2026

CLA assistant check
All committers have signed the CLA.

@pimterry
Copy link
Member

Thanks for the PR @PenguinDevs!

This is indeed sort-of redundant (in that injecting the prepend-node.js script should be handled by $NODE_OPTIONS in most cases) but this script exists specifically to cover the case where that doesn't work. There's a few different scenarios where that variable gets reset by something or is ignored for some reason, and so this wrapper acts as a fallback. Without the -r here this script basically does nothing at all.

I think we could just change from -r to --require though, if that works. Can you try that change here instead, and test whether it works for your case?

@PenguinDevs
Copy link
Author

After changing -r to --require, I end up with the error that:

Error: Cannot find module 'C:\Users\Jason\Documents\VSCode\Random\httptoolkit-server\overrides\path\..\js\prepend-node.js C:/Users/Jason/Documents/VSCode/Random/httptoolkit-server/overrides/js/prepend-node.js'

Which seems like two identical paths - except one is in backslashes, and the other uses forward slashes - are concatenated together? Again, this also only exclusively happens with the newer Next.js versions mentioned in #168 but isn't an issue with older ones. I am able to npm run dev on an older Next.js project with either -r or having it replaced with --require works.

$ echo $NODE_OPTIONS
--require C:/Users/Jason/Documents/VSCode/Random/httptoolkit-server/overrides/js/prepend-node.js

Whether I included the --require or not, it was still being passed to the NODE_OPTIONS, hence why I had omitted it in the PR.

Although I understand that there might be a few scenarios where these options aren't passed to node, what I'm dealing with also appears to be a one-off scenario, too, with the latest Next.js version.

On a side note, I've been finding this tool very handy in various situations and projects. Thank you so much for the Pro account for free use during my studies!

@TMUinsure
Copy link

@pimterry Can you please review the comment above. It would be great if we could get this fixed.

@pimterry
Copy link
Member

Which seems like two identical paths - except one is in backslashes, and the other uses forward slashes - are concatenated together?

I've done some testing - it seems that Next.js basically just doesn't support multiple --require options. Honestly it's all a bit of a mess, I'm really not clear why they're handling this at all given that Node does all of this out of the box. I've added a comment on vercel/next.js#77550 (comment) in the Next.js repo, hopefully they'll look into this.

That said, I think I've found a way to work around this without breaking the existing use cases (by detecting NODE_OPTIONS explicitly, to only set --require when it's really necessary). I've pushed a new change here, updating the two node override scripts. Can the two of you please check this out locally and let me know if it solves the issue for you?

@TMUinsure
Copy link

Thanks @pimterry, very much appreciated. I am unable to test this locally right now but will give it a go later this week when i get back to my personal laptop. Really appreciate your time on this.

@PenguinDevs
Copy link
Author

PenguinDevs commented Jan 20, 2026

Hey Tim,

Thanks for getting back at this with a solution. I tested it just now on Windows and noticed that the NODE_OPTIONS that already existed is using the UNIX forward-slash path instead of the Windows backslashes, because I was still seeing:
Error: Cannot find module 'C:\Users\Jason\Documents\VSCode\Random\httptoolkit-server\overrides\path\..\js\prepend-node.js C:/Users/Jason/Documents/VSCode/Random/httptoolkit-server/overrides/js/prepend-node.js'

I've made a push for it to substitute the \ with / instead.

@PenguinDevs
Copy link
Author

Just tested it on linux too with the Next.js project I was working on, and it's all good there as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants