| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| // from realpath(__filename) but with eval there is no filename | ||
| const mainPaths = ['.'].concat(Module._nodeModulePaths('.'), modulePaths); | ||
| // from realpath(__filename) but in REPL there is no filename | ||
| const mainPaths = ['.']; |
There was a problem hiding this comment.
With --eval, parent has both id and filename set now, so I think this edge case wasn't for --eval anymore but for REPL mode.
> node --eval 'console.log(module)'
Module {
id: '[eval]',
path: '.',
exports: {},
parent: undefined,
filename: '/Users/zyszys/Projects/nodejs/node/[eval]',
loaded: false,
children: [],
paths: [
'/Users/zyszys/Projects/nodejs/node/node_modules',
'/Users/zyszys/Projects/nodejs/node_modules',
'/Users/zyszys/Projects/node_modules',
'/Users/zyszys/node_modules',
'/Users/node_modules',
'/node_modules'
]
}
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
This does seem correct. It would still be good to get another review from e.g. @devsnek or @guybedford though.
Sorry, something went wrong.
There was a problem hiding this comment.
Can you confirm that node --eval 'require("pkg")' where the file system looks like:
/path/to/cwd/ /path/to/node_modules/pkg/index.js
and the node process is running in the /path/to/cwd/ folder?
If we are cutting off those node_modules lookups that seems odd to me.
Edit: Misunderstood this was a relative code path, all seems good.
Sorry, something went wrong.
There was a problem hiding this comment.
Seems good. Missed that this code path is specifically for relative modules (seems I incorrectly expected that resolveLookupPaths would never even apply to relative paths in the first place).
Sorry, something went wrong.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes: #30808
In REPL, module.filename is null, and for relative path modules, we shouldn't look up relative modules from node_modules.
Checklist