I have this file structure:

app.js
console.log( require.resolve('./hello') );
package.json
{
"main": "test"
}
other files are empty.
run: node app.js
if rely on the documentation require should find file underlined in the picture below:

hello.js
but it finds this:

test.js
It should find file in step 3.a but it finds in step 3.b

I guess this how to interpret the module loading logic - my annotations in grey:
Input:
X=./hello
Y=/require_test
[TRUE]['/require_test' + './hello'] = ['./require_test/hello']LOAD_AS_FILE(X) [X='./require_test/hello']
[FAILS AS X is a folder now]
LOAD_AS_DIRECTORY(X)
X=['./require_test/hello']
[TRUE][TRUE], test./require_test/hello/testDONE!It is working as per the documentation. Closing as answered, let me know if you think otherwise.
I think this is addressed by https://github.com/nodejs/node/pull/15015?
@smkoyan this was indeed a bug and it was fixed recently. It was fixed recently by https://github.com/nodejs/node/pull/15015.
@richardlau racy :D
It is handled as semver-major because it was wrong for a very long time and there is a chance that code relies on the faulty behavior. So it will only be released in v.10.0.0.
@BridgeAR / @richardlau - can you please clarify for my understanding? - I don't see any deviation from the doc, nor I see a doc update as part of #15015!
@gireeshpunathil the issue is this part of your annotations:
LOAD_AS_FILE(X)
[X='./require_test/hello']
[FAILS AS X is a folder now]
This describes the incorrect behaviour, it should not fail here and X should be tried as a file. https://github.com/nodejs/node/pull/15015 fixes the behaviour so that it matches the doc.
ah! ok, thanks @richardlau for the clarification.
Most helpful comment
@richardlau racy :D
It is handled as semver-major because it was wrong for a very long time and there is a chance that code relies on the faulty behavior. So it will only be released in v.10.0.0.