Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't exec prettier #1010

Closed
smorimoto opened this issue Nov 18, 2019 · 3 comments · Fixed by #1018
Closed

Can't exec prettier #1010

smorimoto opened this issue Nov 18, 2019 · 3 comments · Fixed by #1018
Labels

Comments

@smorimoto
Copy link
Contributor

Actual behavior:

When I try to exec Prettier, I get the following error:

[project_path]/_esy/default/pnp.js:2177
    for (const path of paths) {
                       ^

TypeError: paths is not iterable
    at Function.Module._findPath ([project_path]/_esy/default/pnp.js:2177:24)
    at resolveMainPath (internal/bootstrap/pre_execution.js:447:28)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1138:24)
    at internal/main/run_main_module.js:16:11

Expected behavior:

We should be able to exec it.

Additional steps to reproduce:

esy add prettier
esy prettier --write '**/*.md'
@bryphe
Copy link
Collaborator

bryphe commented Nov 20, 2019

Added some extra notes from our investigation in Onivim in onivim/oni2#945

looks like esy generates a pnp.js file from here:

Module._findPath = function(request, paths, isMain) {

...and in that spot, it 'monkey-patches' the Module._findPath module resolution logic. It seems that, in Node 13+, that paths can now be null.

Looking at the original implementation: https://github.com/nodejs/node/blob/efce655c0f1671d0e86b5c89092ac93db983ef94/lib/internal/modules/cjs/loader.js#L617 it seems it checks if the path is absolute, if it is, it just uses [''] for paths- otherwise it validates it is non-null and an array. Seems like we might need to bring some of that logic over to esy.

Seems specific to Node v13+ - @CrossR confirmed that Node 12 works, but Node 13 does not.

@CrossR
Copy link
Contributor

CrossR commented Nov 20, 2019

Looking at the original implementation: https://github.com/nodejs/node/blob/efce655c0f1671d0e86b5c89092ac93db983ef94/lib/internal/modules/cjs/loader.js#L617 it seems it checks if the path is absolute, if it is, it just uses [''] for paths- otherwise it validates it is non-null and an array. Seems like we might need to bring some of that logic over to esy.

Hardly scientific or thorough, but blindly copying that logic over into my generated pnp.js did allow esy bootstrap to run in Oni2.

@andreypopp andreypopp added the bug label Nov 27, 2019
@andreypopp
Copy link
Member

Related to #930

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants